Home

Awesome

node-startup

Startup script for Linux-based systems for running a Node.js app when rebooting, using an /etc/init.d script.

Looking for a maintainer

If you use node-startup and would like to be a maintainer, send me a message.

Installation

Clone the repo:

git clone https://github.com/chovy/node-startup.git
cd node-startup/init.d

Edit the node-app script with your settings from the Configuration section, then follow instructions in the Running section.

Configuration

At the top of the node-app file, a few items are declared which are either passed to the Node.js app or used for general execution/management.

Node.js Config

The items declared and passed to the Node.js application are:

Execution Config

The items declared and used by the overall management of executing the application are:

Available Actions

The service exposes 4 actions:

Testing

Test that it all works:

/etc/init.d/node-app start
/etc/init.d/node-app status
/etc/init.d/node-app restart
/etc/init.d/node-app stop

Add node-app to the default runlevels:

# Debian
update-rc.d node-app defaults
# RHEL, --del to remove
chkconfig --add node-app

Finally, reboot to be sure the Node.js application starts automatically:

Force Action## Why node-startup?

When my VPS was rebooted occassionally by the hosting provider, my Node.js app was not coming back online after boot. This script can be used in /etc/init.d, which will allow rc.d to restart your app when the machine reboots without your knowledge.

If you are using MongoDB, Redis, or Nginx, you want to add those to your default run-level as well.

Running

Copy the startup script node-app to your /etc/init.d directory:

sudo bash -l
cp ./init.d/node-app /etc/init.d/

In addition to the start, stop, and restart actions, a --force option can be added to the execution so that the following scenarios have the following outcomes:

Supported OS

Tested with Debian 6.0, but it should work on other Linux systems that use startup scripts in /etc/init.d (Red Hat, CentOS, Gentoo, Ubuntu, etc.).

LICENSE

(The MIT License)

Bitdeli Badge