×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Ruby
Posted by: petecocoon
Added: Jul 28, 2011 10:22 AM
Views: 973
- Change the first line with your interpreter path or just use 'env'
  1. #This is the /etc/init.d/mydaemon file
  2.  
  3. #!/usr/local/bin/bootup_ruby
  4. APP_NAME = 'MyScript'  
  5. APP_PATH = '/my/daemon/file'
  6. case ARGV.first    
  7.   when 'start'  
  8.     puts "Starting #{APP_NAME}..."
  9.     system(APP_PATH, 'start')
  10.   when 'stop'
  11.     system(APP_PATH, 'stop')
  12.   when 'restart'
  13.     system(APP_PATH, 'restart')
  14. end
  15.  
  16. unless %w{start stop restart}.include? ARGV.first
  17.   puts "Usage: #{APP_NAME} {start|stop|restart}"
  18.   exit
  19. end
  20.  
  21. #this is /my/daemon/file
  22.  
  23. #!/usr/local/bin/bootup_ruby
  24. require 'rubygems'
  25. require 'daemons'
  26. Daemons.run('main.rb')
  27.  
  28. #main.rb is the real script