Skip to content
Snippets Groups Projects
Commit d9f3a3e1 authored by Vladimir Petrigo's avatar Vladimir Petrigo
Browse files

Update init script and node-red user recipes

Now the init script uses node-red user as a Node-RED process holder.
Node-RED settings.js is modified to use 8080 port to listen
parent a5ba83f0
No related branches found
No related tags found
No related merge requests found
......@@ -15,31 +15,35 @@ DAEMON_ARGS="--max-old-space-size=128 -s ${SETTINGS}"
LOG_DIR="/var/log/node-red"
LOG="${LOG_DIR}/node-red.log"
PID=/run/node-red.pid
USER=node-red
USER_GROUP=node-red
if [[ ! -e ${LOG_DIR} ]]; then
mkdir -p ${LOG_DIR}
fi
chown -R $USER:$USER_GROUP ${LOG_DIR}
case "$1" in
start)
echo -n "Starting $NAME: "
start-stop-daemon --start --quiet --background --make-pidfile \
start-stop-daemon --start --quiet --background --make-pidfile --chuid $USER:$USER_GROUP \
--pidfile $PID --name $NAME --startas /bin/bash -- -c "exec $DAEMON $DAEMON_ARGS > $LOG 2>&1"
echo "$NAME."
;;
stop)
echo -n "Stopping $NAME: "
start-stop-daemon --stop --quiet --name $NAME --pidfile $PID \
start-stop-daemon --stop --quiet --name $NAME --user $USER --pidfile $PID \
--retry 30 --signal INT
rm -f $PID
echo "$NAME."
;;
restart)
echo -n "Restarting $NAME: "
$0 stop
sleep 1
$0 start
echo "$NAME."
echo "Restarting $NAME..."
$0 stop
sleep 1
$0 start
echo "Done."
;;
*)
N=/etc/init.d/$NAME
......
......@@ -20,7 +20,7 @@
module.exports = {
// the tcp port that the Node-RED web server is listening on
uiPort: 80,
uiPort: %PORT%,
// By default, the Node-RED UI accepts connections on all IPv4 interfaces.
// The following property can be used to listen on a specific interface. For
......
......@@ -13,7 +13,9 @@ SRC_URI = "file://settings.js"
S = "${WORKDIR}"
NODERED_WORKDIR = "${localstatedir}/node-red"
NODERED_PORT = "8080"
NODERED_USER = "node-red"
NODERED_GROUP = "node-red"
inherit useradd
......@@ -25,9 +27,10 @@ do_install_append() {
install -d -m 0755 ${D}${datadir}/node-red
install -m 644 settings.js ${D}${datadir}/node-red
sed -i 's,%WORKDIR%,${NODERED_WORKDIR}/,g' ${D}${datadir}/node-red/settings.js
sed -i 's,%PORT%,${NODERED_PORT},g' ${D}${datadir}/node-red/settings.js
install -d 0755 ${D}${NODERED_WORKDIR}
chown ${NODERED_USER}:node-red -R ${D}${NODERED_WORKDIR}
chown -R ${NODERED_USER}:${NODERED_GROUP} ${D}${NODERED_WORKDIR}
}
FILES_${PN} += " \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment