Skip to content

Commit

Permalink
fix restartOnCrash default
Browse files Browse the repository at this point in the history
  • Loading branch information
hobbyquaker committed Jan 3, 2019
1 parent 901f672 commit ed81e67
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
14 changes: 13 additions & 1 deletion addon_files/redmatic/bin/redmaticLoader
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ WWW_DIR=/usr/local/etc/config/addons/www/redmatic
NODE=$ADDON_DIR/bin/node

export PATH=$ADDON_DIR/bin:$PATH
export LD_LIBRARY_PATH=$ADDON_DIR/lib:$LD_LIBRARY_PATH
export HOME=$ADDON_DIR/home

export NO_UPDATE_NOTIFIER=true
Expand All @@ -20,16 +21,27 @@ status=1
restarts=0
limit=`jq '.restartOnCrash' $ADDON_DIR/etc/settings.json`

if [[ -z $limit ]]; then
limit = 0
fi

while [[ $status != 0 ]]; do
echo $restarts > $ADDON_DIR/var/restart_count
echo "Starting Node-RED" | logger -p daemon.info -t redmatic
if [[ $restarts -gt 0 ]]; then
echo "Restarting Node-RED ($restarts/$limit)" | logger -p daemon.warn -t redmatic
else
echo "Starting Node-RED" | logger -p daemon.info -t redmatic
fi
set -o pipefail
$NODE $RED -s $SETTINGS 2>&1 | logger -p daemon.err -t node-red
status=$?
if [[ $status != 0 ]]; then
echo "Node-RED exited with non-zero exit status $status" | logger -p daemon.err -t node-red
let "restarts=restarts+1"
if [[ $restarts -gt $limit ]]; then
if [[ $limit -gt 0 ]]; then
echo "Maximum Node-RED restarts exceeded" | logger -p daemon.err -t redmatic
fi
status=0
fi
fi
Expand Down
3 changes: 2 additions & 1 deletion addon_files/redmatic/etc/default-settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@
"default": {
"module": "localfilesystem"
}
}
},
"restartOnCrash": 0
}

0 comments on commit ed81e67

Please sign in to comment.