Guest User

Untitled

a guest
May 2nd, 2018
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. # This is the actual config file used to keep the mongrels of
  2. # mydomain.com running.
  3.  
  4. RAILS_ROOT = "/home/user/public_html/project/current"
  5. RAILS_SHARED = "/home/user/public_html/project/shared"
  6.  
  7. %w{8000 8001 8002}.each do |port|
  8. God.watch do |w|
  9. w.name = "mydomain-mongrel-#{port}"
  10. w.interval = 30.seconds # default
  11. w.start = "mongrel_rails start -c #{RAILS_ROOT} -p #{port} \
  12. -P #{RAILS_ROOT}/log/mongrel.#{port}.pid -d"
  13. w.stop = "mongrel_rails stop -P #{RAILS_ROOT}/log/mongrel.#{port}.pid"
  14. w.restart = "mongrel_rails restart -P #{RAILS_ROOT}/log/mongrel.#{port}.pid"
  15. w.start_grace = 10.seconds
  16. w.restart_grace = 10.seconds
  17. w.pid_file = File.join(RAILS_SHARED, "pids/mongrel.#{port}.pid")
  18.  
  19. w.behavior(:clean_pid_file)
  20.  
  21. w.start_if do |start|
  22. start.condition(:process_running) do |c|
  23. c.interval = 5.seconds
  24. c.running = false
  25. c.notify = 'user'
  26. end
  27. end
  28.  
  29. w.restart_if do |restart|
  30. restart.condition(:memory_usage) do |c|
  31. c.above = 150.megabytes
  32. c.times = [3, 5] # 3 out of 5 intervals
  33. c.notify = 'user'
  34. end
  35.  
  36. restart.condition(:cpu_usage) do |c|
  37. c.above = 50.percent
  38. c.times = 5
  39. c.notify = 'user'
  40. end
  41. end
  42.  
  43. # lifecycle
  44. # lifecycle
  45. w.lifecycle do |on|
  46. on.condition(:flapping) do |c|
  47. c.to_state = [:start, :restart]
  48. c.times = 5
  49. c.within = 5.minute
  50. c.transition = :unmonitored
  51. c.retry_in = 10.minutes
  52. c.retry_times = 5
  53. c.retry_within = 2.hours
  54. c.notify = 'user'
  55. end
  56. end
  57. end
  58. end
  59.  
  60. require 'tlsmail'
  61. Net::SMTP.enable_tls(OpenSSL::SSL::VERIFY_NONE)
  62.  
  63. God::Contacts::Email.message_settings = {
  64. :from => 'admin@mydomain.com'
  65. }
  66.  
  67. God::Contacts::Email.server_settings = {
  68. :address => 'smtp.gmail.com',
  69. :tls => 'true',
  70. :port => 587,
  71. :domain => 'mydomain.com',
  72. :authentication => :plain,
  73. :user_name => 'admin@mydomain.com',
  74. :password => '********'
  75. }
  76.  
  77. God.contact(:email) do |c|
  78. c.name = 'user'
  79. c.email = 'user@mydomain.com'
  80. end
Add Comment
Please, Sign In to add comment