Skip to content

Instantly share code, notes, and snippets.

@taf2
Created December 17, 2009 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taf2/258973 to your computer and use it in GitHub Desktop.
Save taf2/258973 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
UNICORN_RAILS="/var/www/apps/ruby/bin/unicorn_rails".freeze
APP_PATH="/var/www/apps/jjsingh/current/".freeze
class Runner
class << self
def start
system "#{UNICORN_RAILS} -c #{APP_PATH}/config/unicorn.rb -E production -D"
end
def reload
system "kill -s USR2 #{pid}"
end
def restart
stop
start
end
def graceful_stop
system "kill -s QUIT #{pid}"
end
def stop
system "kill #{pid}"
end
def pid
File.read "#{APP_PATH}/tmp/pids/unicorn.pid"
end
end
end
case ARGV[0]
when "start"
Runner.start
when "reload"
Runner.reload
when "restart"
Runner.restart
when "stop"
Runner.stop
else
STDERR.puts "usage ./script/spin [start|stop|restart]"
exit(1)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment