System V init script template
A simple template for init scripts that provide the start, stop, restart and status commands.
Handy for Node.js apps and everything else that runs itself.
Copy template to /etc/init.d and rename it to something meaningful. Then edit the script and enter that name after Provides: (between ### BEGIN INIT INFO and ### END INIT INFO).
Now set the following three variables in the script:
The working directory of your process.
The command line to start the process.
The user that should execute the command (optional).
If not set, the command will be called as root (via
Here's an example for an app called algorithms:
dir="/var/apps/algorithms" cmd="node server.js" user="node"
Starts the app.
Stops the app.
Restarts the app.
Tells you whether the app is running. Exits with 0 if it is and 1 otherwise.
By default, standard output goes to /var/log/scriptname.log and
error output to /var/log/scriptname.err. If you're not happy with
that, change the variables
Copyright (C) 2012-2014 Felix H. Dahlke
This is open source software, licensed under the MIT License. See the file LICENSE for details.