I have created a bash script inside /etc/init.d on raspbian jessie - pixel. The script is as follow:
auto_announce
#! /bin/bash
#/etc/init.d/auto_announce
### BEGIN INIT INFO
# Provides: auto_announce
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
amixer cset numid=3 1
(cd /home/pi/vehicle_anouncement_system/ && forever start app.js) && (python /home/pi/vehicle_anouncement_system/simulation.py)
What I need to do is:
start forever on app.js: forever start app.js
After the forever is started, run the python script simulation.py: python simulation.py
The problem is forever starts successfully but the python script doesn't run.
When I run the above script in terminal using ./auto_announce
, the script works perfectly. But it isn't working perfectly on system boot.
What am I missing? Is there a way to log the output of the above script to find out what is causing the problem?
Thanks.
Probably forever start app.js
takes sometime to execute,so put some sleep before executing python /home/pi/vehicle_anouncement_system/simulation.py
.
i.e. try (cd /home/pi/vehicle_anouncement_system/ && forever start app.js) && (sleep 20) && (python /home/pi/vehicle_anouncement_system/simulation.py)