Skip to content

Instantly share code, notes, and snippets.

@UVClay
Created August 7, 2014 15:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save UVClay/f93a5d496fd13260ca4a to your computer and use it in GitHub Desktop.
Save UVClay/f93a5d496fd13260ca4a to your computer and use it in GitHub Desktop.
/etc/init.d/synctube
# /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