Create a gist now

Instantly share code, notes, and snippets.

# This script work on any system using systemd as the init process.
# It works on Debian/Raspbian Jessie.
# If you have Debian/Rapbian Wheezy and want to use this script with systemd
# follow the information here :
# To easily download, install and set at startup:
# wget -O /tmp/download && sudo tar -zxf /tmp/download --strip-components 1 -C /etc/systemd/system/ && sudo systemctl --reload-daemon && sudo systemctl enable Node-RED
# To consult the log : journalctl -u Node-RED
Description=Node-RED is a tool for wiring together hardware devices, APIs and online services in new and interesting ways.
#Full Path to Node.js
ExecStart=/usr/local/bin/node $NODE_OPTIONS red.js $NODE_RED_OPTIONS
# User/Group that launches node-RED (it's advised to create a new user for Node-RED)
# You can do : sudo useradd node-red
# then change the User=root by User=node-red
# Make Node-RED restart if it fails
# Node-RED need a SIGINT to be notified to stop
cormad commented Dec 6, 2015

I tried your instructions on a new install and received the following error;

/tmp/download 100%[=====================>] 1.16K --.-KB/s in 0s

2015-12-06 21:18:04 (2.45 MB/s) - ‘/tmp/download’ saved [1190/1190]

gzip: stdin has more than one entry--rest ignored
tar: Child returned status 2
tar: Error is not recoverable: exiting now

kcagras commented Aug 24, 2016


krisklosterman commented Oct 28, 2016 edited

This is what I did on Debian 8

I installed Node Red with NPM as global
I Created a user named nodered

I then ran these commands as root or with sudo

wget -O /etc/systemd/system/Node-Red.service

vim /etc/systemd/system/Node-Red.service
You then need to modify it and change users and groups and change the following lines:

ExecStart to ExecStart=/usr/bin/node-red

WorkingDirectory to WorkingDirectory=/home/nodered/.node-red/ (This is because I used a user I created called nodered)

you can delete the two Environment lines too

then run

systemctl daemon-reload

systemctl enable Node-Red.service

systemctl start Node-Red.service

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment