Created
October 3, 2011 04:55
-
-
Save zloydadka/1258463 to your computer and use it in GitHub Desktop.
Write a simple init.d ruby startup script
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/local/bin/bootup_ruby | |
# this is /my/daemon/file | |
require 'rubygems' | |
require 'daemons' | |
Daemons.run('main.rb') | |
#main.rb is the real script |
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/local/bin/bootup_ruby | |
# This is the /etc/init.d/mydaemon file | |
APP_NAME = 'MyScript' | |
APP_PATH = '/my/daemon/file' | |
case ARGV.first | |
when 'start' | |
puts "Starting #{APP_NAME}..." | |
system(APP_PATH, 'start') | |
when 'stop' | |
system(APP_PATH, 'stop') | |
when 'restart' | |
system(APP_PATH, 'restart') | |
end | |
unless %w{start stop restart}.include? ARGV.first | |
puts "Usage: #{APP_NAME} {start|stop|restart}" | |
exit | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment