Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- app_name = '<%= application %>'
- rails_root = '<%= deploy_to %>/current'
- unicorn_bin = '<%= unicorn_bin %>'
- unicorn_pid = '<%= unicorn_pid %>'
- unicorn_config = '<%= unicorn_remote_config %>'
- unicorn_start_cmd = '<%= unicorn_start_cmd %>'
- unicorn_stop_cmd = '<%= unicorn_stop_cmd %>'
- unicorn_restart_cmd = '<%= unicorn_restart_cmd %>'
- # Unicorn
- God.watch do |w|
- unicorn(w, rails_root,
- :memory_limit => 150.megabytes,
- :cpu_limit => 50.percent,
- :bin_unicorn => unicorn_bin,
- :name => app_name,
- :rails_root => rails_root,
- :unicorn_conf => unicorn_config,
- :unicorn_pid => unicorn_pid,
- :start_cmd => unicorn_start_cmd,
- :stop_cmd => unicorn_stop_cmd,
- :restart_cmd => unicorn_restart_cmd,
- :user => '<%= unicorn_user %>',
- :group => '<%= unicorn_group %>')
- end
- #Redis
- God.watch do |w|
- w.name = "redis"
- w.uid = "root"
- w.dir = "#{rails_root}"
- w.interval = 60.seconds
- w.start = "/etc/init.d/redis-server start"
- w.stop = "/etc/init.d/redis-server stop"
- w.start_grace = 10.seconds
- w.restart_grace = 10.seconds
- w.behavior(:clean_pid_file)
- w.pid_file = "#{rails_root}/tmp/pids/redis.pid"
- w.start_if do |start|
- start.condition(:process_running) do |c|
- c.interval = 5.seconds
- c.running = false
- end
- end
- w.restart_if do |restart|
- restart.condition(:memory_usage) do |c|
- c.above = 150.megabytes
- c.times = [3, 5] # 3 out of 5 intervals
- end
- restart.condition(:cpu_usage) do |c|
- c.above = 50.percent
- c.times = 5
- end
- end
- # lifecycle
- w.lifecycle do |on|
- on.condition(:flapping) do |c|
- c.to_state = [:start, :restart]
- c.times = 5
- c.within = 5.minute
- c.transition = :unmonitored
- c.retry_in = 10.minutes
- c.retry_times = 5
- c.retry_within = 2.hours
- end
- end
- end
Add Comment
Please, Sign In to add comment