Skip to content

keepwondering/pleasure-daemonizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Classes

RunningProcess

Holds the information of a running process

DaemonizerServer
Daemonizer

Typedefs

RunningProcessOptions : Object

Spawn arguments

SpawnArgs : Object

Spawn arguments

ENV : Object

Environmental variables

DaemonizerConfig : Object

RunningProcess

Holds the information of a running process

Kind: global class

new RunningProcess(id, spawnArgs, options)

Param Type Description
id String The command to run.
spawnArgs SpawnArgs Spawn arguments
options RunningProcessOptions Configuration options

runningProcess.start()

Runs the program

Kind: instance method of RunningProcess

runningProcess.restart()

Re-starts the program

Kind: instance method of RunningProcess

runningProcess.stop()

Re-starts the program

Kind: instance method of RunningProcess

DaemonizerServer

Kind: global class
Classdec: DaemonizerDaemon is the process manager that creates and control multiple spawned processes to monitor.

daemonizerServer.findProcessById(id) ⇒ RunningProcess | void

Returns a RunningProcess given an id.

Kind: instance method of DaemonizerServer
Returns: RunningProcess | void - The running process

Param Type Description
id String SubProcess id (different than pid)

daemonizerServer.findProcessByPid(pid) ⇒ RunningProcess | void

Returns a RunningProcess given an id.

Kind: instance method of DaemonizerServer
Returns: RunningProcess | void - The running process

Param Type Description
pid String Process id

daemonizerServer.fork(id, spawnArgs, processOptions)

Forks a process & starts monitoring it

Kind: instance method of DaemonizerServer

Param Type Description
id String Optional identifier for the process. If none if provided, the system will automatically try to guess one.
spawnArgs SpawnArgs
processOptions RunningProcessOptions

daemonizerServer.stop(id)

Kind: instance method of DaemonizerServer

Param Type
id String

DaemonizerServer.isRunning([config]) ⇒ Number | void

Kind: static method of DaemonizerServer
Returns: Number | void - Returns the process id (pid) when the process is running. void otherwise.

Param Type Description
[config] DaemonizerConfig Defaults to default config.

DaemonizerServer.start(config, env) ⇒ Number

Kind: static method of DaemonizerServer
Returns: Number - The process id (pid).
Throws:

  • Error Throws 'Another process is already running (pid = ${ runningPid })' when a process is already running.
Param Type Description
config DaemonizerConfig Defaults to default config.
env Object Environment key-value pairs.

Daemonizer

Kind: global class
Classdec: Daemonizer is a process manager that creates an instance to control multiple spawned processes to monitor.

daemonizer.fork(id, spawnArgs, processOptions)

Daemonizes a terminal application by sending the request to the running DaemonizerDaemon.

Kind: instance method of Daemonizer

Param Type Description
id String The command to run.
spawnArgs SpawnArgs List of string arguments.
processOptions RunningProcessOptions List of string arguments.

RunningProcessOptions : Object

Spawn arguments

Kind: global typedef
See: child_process.spawn
Properties

Name Type Default Description
[options.autoRestart] Boolean true Whether to automatically restart the application after failure.
[options.waitBeforeRestart] Number 1000 Milliseconds to wait before triggering autoRestart.
[options.maximumAutoRestart] Number 100 Maximum amount of time the process can be autorestarted. Negative for infinite.

SpawnArgs : Object

Spawn arguments

Kind: global typedef
See: child_process.spawn
Properties

Name Type Description
command String The command to run.
args Array List of string arguments.
options Object child_process.spawn options.

ENV : Object

Environmental variables

Kind: global typedef
Properties

Name Type Description
[DAEMONIZER_CONFIG] String JSON stringified string with default DaemonizerConfig configuration options.
[DAEMONIZER_DAEMON_START] Boolean When true, triggers automatically start

DaemonizerConfig : Object

Kind: global typedef
Properties

Name Type Default Description
[runningThread] String ../.running Path to file for storing information about the running thread.
port Number Port where socket.io will listen for connections.
ip String IP address where socket.io will bind.

© 2019 Martin Rafael [email protected]

About

pleasure's process manager

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published