Skip to content

Commit

Permalink
Log for daemon
Browse files Browse the repository at this point in the history
  • Loading branch information
christianTF committed Feb 17, 2020
1 parent 3507faa commit ad0b274
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions daemon/daemon
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
#!/bin/bash
log="REPLACELBPLOGDIR/daemonstart.log"
echo "MQTT Gateway Daemon start" > $log

echo "Running updateconfig.pl to query json" >> $log
# Request if local Mosquitto is enabled
MOSQENABLED="$(REPLACELBPBINDIR/updateconfig.pl section=Main param=enable_mosquitto)"
echo "Result is $MOSQENABLED" >> $log

if [ "$MOSQENABLED" -eq "1" ]; then
for i in {1...100}
do
echo "Try $i: Checking if Mosquitto is running..." >> $log
# Check if it is running
pgrep mosquitto
exitcode=$?
if [[ $exitcode != 0 ]]; then
# Restart if not
echo " Restarting..." >> $log
systemctl restart mosquitto.service
echo " Sleeping 10 s..." >> $log
sleep 10
fi
done
fi

echo "Starting mqttgateway.pl" >> $log
su loxberry -c "cd REPLACELBPBINDIR ; REPLACELBPBINDIR/mqttgateway.pl > /dev/null 2>&1 &"

0 comments on commit ad0b274

Please sign in to comment.