Skip to content

Instantly share code, notes, and snippets.

@esmooov
Created September 10, 2010 14:08
Show Gist options
  • Save esmooov/573694 to your computer and use it in GitHub Desktop.
Save esmooov/573694 to your computer and use it in GitHub Desktop.
#!/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