Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2012
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. RAILS_ENV = ENV['RAILS_ENV'] || "production"
  2. RAILS_ROOT = ENV['RAILS_ROOT'] || "/var/www/apps/advicecapital/current"
  3. PID_DIR = #"#{RAILS_ROOT}/log"
  4.  
  5. God.pid_file_directory = "#{PID_DIR}"
  6.  
  7. God.watch do |w|
  8. w.name = "clockwork"
  9. w.interval = 30.seconds
  10. w.env = { "RAILS_ENV" => RAILS_ENV }
  11. w.dir = "#{RAILS_ROOT}"
  12.  
  13. w.start = "bundle exec clockwork #{RAILS_ROOT}/config/clock.rb"
  14. w.stop = "kill -QUIT `cat #{PID_DIR}/clockwork.pid`"
  15. w.restart = "kill -QUIT `cat #{PID_DIR}/clockwork.pid` && bundle exec clockwork #{RAILS_ROOT}/config/clock.rb"
  16. w.log = "#{RAILS_ROOT}/log/clockwork.log"
  17.  
  18. w.start_grace = 10.seconds
  19. w.restart_grace = 10.seconds
  20. w.pid_file = "#{PID_DIR}/clockwork.pid"
  21.  
  22. w.uid = 'appuser'
  23. w.gid = 'appuser'
  24.  
  25. # clean pid files before start if necessary
  26. w.behavior(:clean_pid_file)
  27.  
  28. # determine the state on startup
  29. w.transition(:init, { true => :up, false => :start }) do |on|
  30. on.condition(:process_running) do |c|
  31. c.running = true
  32. end
  33. end
  34.  
  35. # determine when process has finished starting
  36. w.transition([:start, :restart], :up) do |on|
  37. on.condition(:process_running) do |c|
  38. c.running = true
  39. end
  40.  
  41. # failsafe
  42. on.condition(:tries) do |c|
  43. c.times = 5
  44. c.transition = :start
  45. c.interval = 5.seconds
  46. end
  47. end
  48.  
  49. # start if process is not running
  50. w.transition(:up, :start) do |on|
  51. on.condition(:process_exits)
  52. end
  53.  
  54. # # restart if memory or cpu is too high
  55. # w.transition(:up, :restart) do |on|
  56. # on.condition(:memory_usage) do |c|
  57. # c.interval = 20
  58. # c.above = 50.megabytes
  59. # c.times = [3, 5]
  60. # end
  61. #
  62. # on.condition(:cpu_usage) do |c|
  63. # c.interval = 10
  64. # c.above = 10.percent
  65. # c.times = [3, 5]
  66. # end
  67. # end
  68.  
  69. # lifecycle
  70. w.lifecycle do |on|
  71. on.condition(:flapping) do |c|
  72. c.to_state = [:start, :restart]
  73. c.times = 5
  74. c.within = 5.minute
  75. c.transition = :unmonitored
  76. c.retry_in = 10.minutes
  77. c.retry_times = 5
  78. c.retry_within = 2.hours
  79. end
  80. end
  81.  
  82. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement