node-os Init Daemon
The init process, typically
/sbin/init, is a long-lived process started by the kernel during boot.
Init is responsible for starting system daemons such as
On Ubuntu the init daemon is Upstart.
Upstart, like most init daemons, has the concept of a system runlevel numbered 0-5.
When init starts, it uses the runlevel to decide how to boot the system.
The startup sequence involves parsing files in
The node-os init daemon takes a different approach. The init daemon does nothing except basic job control.
- Init starts an HTTP server on
127.0.0.1:1that can be used to start and stop jobs.
- Init hands control to another process that uses the API to boot the system as desired.
- Init itself does not parse config files.
GET /jobs <-- list all jobsPOST /job <-- start a jobPUT /job/:id <-- start a job with a specific namePUT /job/:id/sig/:sig <-- signal a processGET /job/:id <-- get job infoDELETE /job/:id <-- clear a stopped job
Starting a job requires a JSON payload
- restart semantics
- handling stdio
- pre-opened file-descriptors
- authentication and access control
init [next command and args]
After init starts its HTTP server, it passes the task of booting the system off to another process. You specify the next process by passing the command to init during start. These parameters can, and should, be passed to init by grub.
The next command effectively decides what order to boot system daemons in.
npkg command defined in
node-os-npkg provides a nice interface between init
and NodeJS packages installed on the system.