Guest User

Untitled

a guest
Jun 18th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. rails_root = "/data/github/current"
  2.  
  3. 20.times do |num|
  4. God.watch do |w|
  5. w.name = "dj-#{num}"
  6. w.group = 'dj'
  7. w.interval = 30.seconds
  8. w.start = "rake -f #{rails_root}/Rakefile production jobs:work"
  9.  
  10. w.uid = 'git'
  11. w.gid = 'git'
  12.  
  13. # retart if memory gets too high
  14. w.transition(:up, :restart) do |on|
  15. on.condition(:memory_usage) do |c|
  16. c.above = 300.megabytes
  17. c.times = 2
  18. end
  19. end
  20.  
  21. # determine the state on startup
  22. w.transition(:init, { true => :up, false => :start }) do |on|
  23. on.condition(:process_running) do |c|
  24. c.running = true
  25. end
  26. end
  27.  
  28. # determine when process has finished starting
  29. w.transition([:start, :restart], :up) do |on|
  30. on.condition(:process_running) do |c|
  31. c.running = true
  32. c.interval = 5.seconds
  33. end
  34.  
  35. # failsafe
  36. on.condition(:tries) do |c|
  37. c.times = 5
  38. c.transition = :start
  39. c.interval = 5.seconds
  40. end
  41. end
  42.  
  43. # start if process is not running
  44. w.transition(:up, :start) do |on|
  45. on.condition(:process_running) do |c|
  46. c.running = false
  47. end
  48. end
  49. end
  50. end
Add Comment
Please, Sign In to add comment