commit e69e6fb2dbe57a0db2d26306231936e049896600 Author: David Kebler Date: Thu Jul 2 15:38:21 2020 -0700 initial commit diff --git a/install b/install new file mode 100755 index 0000000..a4df038 --- /dev/null +++ b/install @@ -0,0 +1,9 @@ +#!/bin/bash +sudo rm /etc/systemd/system/node-red@.service +sudo ln -s /opt/node-red-run/node-red.service /etc/systemd/system/ +sudo systemctl daemon-reload +sudo systemctl enable node-red +sudo systemctl restart node-red +sleep 5 +sudo journalctl --unit=node-red -n 50 --no-pager +exit 1 diff --git a/node-red.service b/node-red.service new file mode 100644 index 0000000..d607af7 --- /dev/null +++ b/node-red.service @@ -0,0 +1,23 @@ +[Unit] +Description=Node-RED +After=syslog.target network.target + +[Service] +# uncomment environment and set for alternative user directory, default is /opt/node-red +# run > sudo systemctl daemon-reload +# Environment=NODE_RED_USER_DIR=/opt/node-red +ExecStart=/bin/bash /opt/node-red-run/run ${NODE_RED_USER_DIR} +Restart=on-failure +KillSignal=SIGINT + +# log output to syslog as 'node-red' +SyslogIdentifier=node-red +StandardOutput=syslog + +# non-root user to run as +WorkingDirectory=/opt/node-red +User=sysadmin +Group=sysadmin + +[Install] +WantedBy=multi-user.target diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..d90eaff --- /dev/null +++ b/readme.md @@ -0,0 +1,11 @@ +# Node Red - Runner + +This repo aids in keeping node-red up to date and running via a systemd Service + +install nodered and esm globally + +sudo npm install -g --unsafe-perm node-red && sudo npm install -g esm + + Just clone repo to `/opt` + + you can run the /.start script diff --git a/run b/run new file mode 100755 index 0000000..6c30abf --- /dev/null +++ b/run @@ -0,0 +1,8 @@ +#!/bin/bash +GDIR="/usr/lib/node_modules" # global install +DIR=${1:-$NODE_RED_USER_DIR} +echo any dir set? $DIR +DIR=${DIR:-/opt/node-red} +echo any dir set? $DIR +echo Starting Node Red with instance directory $DIR +/usr/bin/node -r $GDIR/esm $GDIR/node-red/red.js --userDir $DIR diff --git a/start b/start new file mode 100755 index 0000000..1ca8ad5 --- /dev/null +++ b/start @@ -0,0 +1 @@ +sudo systemctl start node-red diff --git a/stop b/stop new file mode 100755 index 0000000..4c31f4c --- /dev/null +++ b/stop @@ -0,0 +1 @@ +sudo systemctl stop node-red diff --git a/update b/update new file mode 100755 index 0000000..bb8eb18 --- /dev/null +++ b/update @@ -0,0 +1,6 @@ +#!/bin/bash +# run global update on node-red and esm +sudo npm install -g --unsafe-perm node-red +sudo npm install -g esm +sudo systemctl daemon-reload +sudo systemctl restart node-red