boss
A node process manager that isn't spanners all the way down.
Features
- Monitoring in console
- Configure user/group to run processes as
- Auto process restart on crash
- Log redirection to per process out/err files
- Web interface with support for monitoring multiple hosts
- Cluster support
Install
npm install -g process-boss
Usage
Comprehensive help is available on the command line:
bs --help
and with more detail for each subcommand, e.g.:
bs start --help
The first time you invoke a boss command, the daemon will start in the background. Because boss can run processes as different users, it needs to be able to switch to those users. Consequently you should run boss as root or another privileged user.
list
bs list
Display a list of processes boss has started.
start
bs start [options] <script>
Start a new process.
args
-h, --help output usage information
-u, --user <user> The user to start a process as
-g, --group <group> The group to start a process as
-i, --instances <instances> How many instances of the process to start (e.g. cluster mode)
-n, --name <name> What name to give the process
-a, --argv <argv> A space separated list of arguments to pass to a process
-e, --execArgv <execArgv> A space separated list of arguments to pass to the node executable
-d, --debug Pause the process at the start of execution and wait for a debugger to be attached
-v, --verbose Prints detailed internal logging output
e.g.
To start http-server.js
as a cluster with two workers, running as alex:staff
and with two command line arguments -a foo
and -b bar
$ bs start -u alex -g staff -i 2 -argv '-a foo -b bar' http-server.js
restart
Restart a running process
bs restart <pid>
stop
Stop a running process.
bs stop <pid>
kill
Stop all processes and kill the daemon. By default all currently running processes will be saved and restarted when boss restarts.
bs kill
cluster
After starting a process with -i $num
(e.g. start ``$num` instances of a script), adjust the number of cluster workers.
bs cluster <pid> <workers>
e.g.
Make process 49308 (previously started with -i 2
) run with 4 workers:
$ bs cluster 49308 4
The maximum workers you can set is dependent on your system as num_cpus - 1
send
Send an event to a process
bs send <pid> <event> [args...]
e.g.
In my script
process
$ bs send 39823 my:custom:event 1 2
// process 39823 then prints '3' to the logs
heapdump
Make a process dump a heap snapshot for analysis in Chrome's debug tools.
bs heapdump <pid>
gc
Force a process to do garbage collection
bs gc <pid>
signal
Send a signal to a process (n.b. unless you have a listener for that signal, your process will most likely exit)
bs signal <pid> <signal>
e.g.
$ bs signal 3984 SIGINT
logs
Show live logs for a process (or all processes if <pid>
is omitted) in the console
bs logs [pid]
dump
Dump a processes.json
file of running processes to $CONFIGDIR
for use with bs restore
bs dump
restore
Restore running processes from $CONFIGDIR/processes.json
bs restore
remoteconfig
For use with boss-web - see boss-web's setup for more information
bs remoteconfig
useradd
To add a user for boss-web - see boss-web's setup for more information. If you specify [hostname]
the configuration output is more likely to be correct.
bs useradd [options] <username> [hostname]
rmuser
To remove a user for boss-web - see boss-web's setup for more information.
bs rmuser <username>
lsuser
To list users for boss-web - see boss-web's setup for more information.
bs lsusers
reset
To reset the secret for a boss-web user - see boss-web's setup for more information.
bs reset <username>
Configure
Boss uses rc so it looks for configuration files in sensible places. The default configuration file looks like:
[boss] ; The user the daemon will run as - this user should have sufficient ; privileges to spawn new processes and then drop their privileges to ; that of other users user = root ; The group the daemon will run as -
See the default config file for more information on the various options.
Discuss: gitter.im/tableflip/boss