Created
September 10, 2010 14:08
-
-
Save esmooov/573694 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env ruby | |
# your choice | |
pid_path = "/var/run/beanstalkd" | |
beanstalkd = "/usr/bin/beanstalkd" | |
beanstalkd_opts = "-d -p 9000" | |
if ["start", "stop"].include? ARGV[0] | |
case ARGV[0] | |
when "start" | |
`#{beanstalkd} #{beanstalkd_opts}` # start beanstalkd | |
`pgrep beanstalkd > #{pid_path}/beanstalkd.pid` # push beanstalks pid to a file | |
when "stop" | |
`killall beanstalkd` # works everytime | |
`rm #{pid_path}/beanstalkd.pid` # remove the pidfile | |
end | |
else | |
puts "usage: beanstalkd.rb {start|stop}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment