Guest User

Untitled

a guest
May 25th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. module Moonshine::Manifest::Rails::God
  2.  
  3. # Installs <tt>god monitoring framework</tt> from gem and installs a config
  4. # to <tt>/etc/god/god.rb</tt>. Adds a config file in
  5. # <tt>/etc/god/apps/<application>.yml</tt> if :delayed_job is set to true in
  6. # moonshine.yml
  7. def god
  8. gem 'god'
  9. file '/etc/god', :ensure => :directory
  10. file '/etc/god/apps', :ensure => :directory
  11. file '/etc/god/god.rb',
  12. :ensure => :present,
  13. :content => template(File.join(File.dirname(__FILE__), 'templates', 'god.rb.erb'))
  14. if configuration[:delayed_job]
  15. file "/etc/god/apps/#{configuration[:server_name]}.yml",
  16. :ensure => :present,
  17. :content => template(File.join(File.dirname(__FILE__), 'templates', 'god_app.yml.erb')),
  18. :before => [ exec("god_start"), exec("god_stop") ]
  19. end
  20. god_restart
  21. end
  22.  
  23. def god_start
  24. exec "god_start",
  25. :command => "sudo god -c /etc/god/god.rb start",
  26. :require => package("god")
  27. end
  28.  
  29. def god_stop
  30. exec "god_stop", :command => "sudo god quit",
  31. :onlyif => "ps aux | grep '/usr/bin/ruby /usr/bin/[g]od'; test \"$?\" -eq 0",
  32. :before => exec("god_start")
  33. end
  34.  
  35. def god_restart
  36. god_stop
  37. god_start
  38. end
  39. end
Add Comment
Please, Sign In to add comment