There are many methods of starting, stopping and monitoring applications at boot time. This guide highlights some of the possible ways of doing it.
The Raspberry Pi install script we provide can be used on any Debian-like operating system.
If you are not using Raspbian, you may need to edit the service file to suit your local user id and environment. Details for how to do that are available here.
We also provide an install script for RPM based linux available here, that also sets up systemd.
The guide below sets out what we believe to be the most straight-forward for the majority of users. For Windows, PM2 does not autorun as a service - you may prefer the NSSM option below.
PM2 is a process manager for Node.js. It makes it easy to run applications on boot and ensure they are restarted if necessary.
sudo npm install -g pm2
sudois required if running as a non-root user on Linux or OS X. If running on Windows, you will need to run in a command shell as Administrator, without the
tail.exeis on your path, as described here.
If you have done a global install of node-red, then on Linux/OS X the
command will probably be either:
which node-red can be used to confirm the location.
If you have done a local install, it will be
relative to where you ran
npm install from.
The following command tells PM2 to run Node-RED, assuming
the location of the
-- argument must appear before any arguments you want to pass to node-red.
pm2 start /usr/bin/node-red -- -v
pm2 start /usr/bin/node-red --node-args="--max-old-space-size=128" -- -v
This will start Node-RED in the background. You can view information about the process and access the log output using the commands:
pm2 info node-red pm2 logs node-red
More information about managing processes under PM2 is available here.
PM2 is able to generate and configure a startup script suitable for the platform it is being run on.
Run these commands and follow the instructions it provides:
pm2 save pm2 startup
for newer Linux systems that use systemd use
pm2 startup systemd
export PM2_HOME="/root/.pm2"to point at the correct directory, which would be like:
Finally, reboot and check everything starts as expected.
PM2 does not autorun as a service on Windows. An alternative option is to use NSSM, an example of which is available from the community link below.
There are many alternative approaches. The following are some of those created by members of the community.