Last active
August 29, 2015 14:02
-
-
Save chris-piekarski/7f12b2b5ea4e7073f8ba to your computer and use it in GitHub Desktop.
Debian - Add Service
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
sudo vi /etc/init.d/cjp | |
sudo chmod +x /etc/init.d/cjp | |
#if you want it to run at startup | |
sudo update-rc.d cjp defaults | |
#to remove | |
sudo update-rc.d -f cjp remove | |
#start and stop at will | |
sudo service cjp start | |
suod service cjp stop | |
example: | |
#!/bin/sh | |
### BEGIN INIT INFO | |
# Provides: CJP | |
# Required-Start: $time $network $remote_fs $syslog $all $redis-server | |
# Required-Stop: $remote_fs $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: Magnatize Highmem initscript | |
# Description: This file should be used to construct scripts to be | |
# placed in /etc/init.d. | |
### END INIT INFO | |
# Carry out specific functions when asked to by the system | |
case "$1" in | |
start) | |
date >> /home/chris/out.txt | |
echo "Starting script cjp" >> /home/chris/out.txt | |
/usr/local/bin/resque-web --app-dir /home/chris/tmp/ --redis 10.240.185.245 2>&1 >> /home/chris/out.txt | |
/usr/local/bin/rake --rakefile /home/chris/tweetstream/examples/Rakefile crunch_it 2>&1 & >> /home/chris/out.txt | |
/usr/local/bin/rake --rakefile /home/chris/tweetstream/examples/Rakefile resque:work QUEUE=tweets_to_scrape 2>&1 & >> /home/chris/out.txt | |
;; | |
stop) | |
echo "Stopping script cjp" >> /home/chris/out.txt | |
/usr/local/bin/resque-web --app-dir /home/chris/tmp --kill | |
kill `ps ax | grep crunch_it | grep -v 'grep' | cut -f 2 -d ' ' -s` 2>&1 >> /home/chris/out.txt | |
kill `ps ax | grep tweets_to_scrape | grep -v 'grep' | cut -f 2 -d ' ' -s` 2>&1 >> /home/chris/out.txt | |
;; | |
*) | |
echo "Usage: /etc/init.d/blah {start|stop}" | |
exit 1 | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment