Created
August 7, 2014 15:04
-
-
Save UVClay/f93a5d496fd13260ca4a to your computer and use it in GitHub Desktop.
/etc/init.d/synctube
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/init.d/synctube | |
### BEGIN INIT INFO | |
# Provides: synctube | |
# Required-Start: $network $syslog | |
# Required-Stop: $network $syslog | |
# Should-Start: $named $time | |
# Should-Stop: $named $time | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: Start the synctube process | |
# Description: Controls the synctube process | |
### END INIT INFO | |
#Define your variables and whatever | |
USER="synctube" | |
start() { | |
echo "Starting synctube" | |
su - $USER -c 'nohup node sync/index.js &' | |
} | |
stop() { | |
echo "Stopping synctube" | |
#assumes no other node processes are running under you're synctube user | |
su - $USER -c 'pkill node' | |
} | |
status() { | |
#assumes no other node processes are running under ur synctube user here as well. | |
pid=`pgrep -u $USER node` | |
if [ -z $pid ] ; then | |
echo "synctube running as $USER: not running." | |
else | |
echo "synctube running as $USER: running." | |
fi | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
restart|reload|force-reload) | |
stop | |
start | |
;; | |
status) | |
status | |
;; | |
*) | |
echo "Usage: /etc/init.d/synctube {start|stop|reload|force-reload|restart|status}" | |
exit 1 | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment