daily pastebin goal
36%
SHARE
TWEET

Untitled

a guest Apr 23rd, 2018 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env ruby
  2. #
  3. # merbctl - Start, stop, restart merb instances
  4. # by: cory odaniel
  5. #
  6.  
  7. APP_ROOT = "/path/to/apps"
  8. ADAPTER = "thin"
  9. CLUSTER_SIZE = 3
  10. GRACEFUL = true
  11. ENVIRONMENT = "development"
  12.  
  13. applications = {
  14.   'appone' => 13000
  15.   'otherapp' => 4000,
  16.   'coolapp' => 5000
  17. }
  18.  
  19.  
  20. #Stop and restart (falls through on restart)
  21. if ['stop', 'restart'].include? ARGV.first
  22.   applications.each do |name, port|
  23.     path = File.join(APP_ROOT, name)
  24.     app_path = File.join(path,"current")
  25.     pid_path = File.join(path,"shared","pids",%{#{ADAPTER}.#{ENVIRONMENT}.pid})
  26.  
  27.     puts "Stopping #{name} ... "
  28.  
  29.     `merb -m #{app_path} -P #{pid_path} -#{GRACEFUL ? "K" : "k"} all`
  30.  
  31.   end
  32. end
  33.  
  34.  
  35. #Start and restart
  36. if ['start', 'restart'].include? ARGV.first
  37.   applications.each do |name, port|
  38.     path = File.join(APP_ROOT, name)
  39.     app_path = File.join(path,"current")
  40.     log_path = File.join(path,"shared","logs",%{#{ADAPTER}.#{ENVIRONMENT}.log})
  41.     pid_path = File.join(path,"shared","pids",%{#{ADAPTER}.#{ENVIRONMENT}.pid})
  42.  
  43.     puts "Starting #{name} on #{port} - #{port + CLUSTER_SIZE - 1} ... "
  44.  
  45.     `merb -m #{app_path} -P #{pid_path} -c #{CLUSTER_SIZE} -p #{port} -a #{ADAPTER} -e #{ENVIRONMENT} -L #{log_path}`
  46.   end
  47. end
  48.  
  49.  
  50. puts "Usage: merbctl {start|stop|restart}" unless ['start', 'stop', 'restart'].include? ARGV.first
RAW Paste Data
Top