Skip to content

Instantly share code, notes, and snippets.

@betamatt
Created April 10, 2011 20:23
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save betamatt/912694 to your computer and use it in GitHub Desktop.
Save betamatt/912694 to your computer and use it in GitHub Desktop.
Faye monit wrapper
#!/usr/env ruby
base_dir = File.expand_path("../..", __FILE__)
NAME="faye"
PID="#{base_dir}/tmp/pids/#{NAME}.pid"
COMMAND="bundle exec rackup -s thin -E production -p 3001 faye.ru"
case ARGV[0]
when "start"
pid = fork do
Dir.chdir(basedir)
exec *COMMAND.split(' ') # fails for quoted args, obviously
end
Process.detach(pid)
File.open(PID, "w+") do |f|
f.write(pid)
end
when "stop"
Process.kill "TERM", File.read(PID).to_i
else
puts "usage: #{$0} {start|stop}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment