Created
September 7, 2009 16:43
-
-
Save oneman/182438 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 | |
# This is a wrapper script for beanstalkd to drop a .pid file so it can be used by monitoring programs ( like monit ) | |
# customise to your needs below | |
# usage: beanstalkd {start|stop} (chmod +x the file ) | |
# assumed file is placed in RAILS_ROOT/script | |
#RAILS_ROOT = "#{File.dirname(__FILE__)}/.." | |
# your choice | |
pid_path = "/var/run/beanstalkd" | |
beanstalkd = "/usr/bin/beanstalkd" | |
beanstalkd_opts = "-d" | |
if ["start", "stop"].include? ARGV[0] | |
case ARGV[0] | |
when "start" | |
`#{beanstalkd} #{beanstalkd_opts}` # start beanstalkd | |
`pgrep -n beanstalkd > #{pid_path}/beanstalkd.pid` # push beanstalks pid to a file | |
when "stop" | |
`killall -9 beanstalkd` # works everytime | |
`rm #{pid_path}/beanstalkd.pid` # remove the pidfile | |
end | |
else | |
puts "usage: beanstalkd {start|stop}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment