Guest User

Untitled

a guest
Jan 22nd, 2018
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. app_name = '<%= application %>'
  2. rails_root = '<%= deploy_to %>/current'
  3. unicorn_bin = '<%= unicorn_bin %>'
  4. unicorn_pid = '<%= unicorn_pid %>'
  5. unicorn_config = '<%= unicorn_remote_config %>'
  6. unicorn_start_cmd = '<%= unicorn_start_cmd %>'
  7. unicorn_stop_cmd = '<%= unicorn_stop_cmd %>'
  8. unicorn_restart_cmd = '<%= unicorn_restart_cmd %>'
  9.  
  10. # Unicorn
  11. God.watch do |w|
  12. unicorn(w, rails_root,
  13. :memory_limit => 150.megabytes,
  14. :cpu_limit => 50.percent,
  15. :bin_unicorn => unicorn_bin,
  16. :name => app_name,
  17. :rails_root => rails_root,
  18. :unicorn_conf => unicorn_config,
  19. :unicorn_pid => unicorn_pid,
  20. :start_cmd => unicorn_start_cmd,
  21. :stop_cmd => unicorn_stop_cmd,
  22. :restart_cmd => unicorn_restart_cmd,
  23. :user => '<%= unicorn_user %>',
  24. :group => '<%= unicorn_group %>')
  25. end
  26.  
  27. #Redis
  28. God.watch do |w|
  29. w.name = "redis"
  30. w.uid = "root"
  31. w.dir = "#{rails_root}"
  32. w.interval = 60.seconds
  33. w.start = "/etc/init.d/redis-server start"
  34. w.stop = "/etc/init.d/redis-server stop"
  35. w.start_grace = 10.seconds
  36. w.restart_grace = 10.seconds
  37. w.behavior(:clean_pid_file)
  38.  
  39. w.pid_file = "#{rails_root}/tmp/pids/redis.pid"
  40.  
  41. w.start_if do |start|
  42. start.condition(:process_running) do |c|
  43. c.interval = 5.seconds
  44. c.running = false
  45. end
  46. end
  47.  
  48. w.restart_if do |restart|
  49. restart.condition(:memory_usage) do |c|
  50. c.above = 150.megabytes
  51. c.times = [3, 5] # 3 out of 5 intervals
  52. end
  53.  
  54. restart.condition(:cpu_usage) do |c|
  55. c.above = 50.percent
  56. c.times = 5
  57. end
  58. end
  59.  
  60. # lifecycle
  61. w.lifecycle do |on|
  62. on.condition(:flapping) do |c|
  63. c.to_state = [:start, :restart]
  64. c.times = 5
  65. c.within = 5.minute
  66. c.transition = :unmonitored
  67. c.retry_in = 10.minutes
  68. c.retry_times = 5
  69. c.retry_within = 2.hours
  70. end
  71. end
  72. end
Add Comment
Please, Sign In to add comment