initial commit

master
David Kebler 2020-07-02 15:38:21 -07:00
commit e69e6fb2db
7 changed files with 59 additions and 0 deletions

9
install Executable file
View File

@ -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

23
node-red.service Normal file
View File

@ -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

11
readme.md Normal file
View File

@ -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

8
run Executable file
View File

@ -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

1
start Executable file
View File

@ -0,0 +1 @@
sudo systemctl start node-red

1
stop Executable file
View File

@ -0,0 +1 @@
sudo systemctl stop node-red

6
update Executable file
View File

@ -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