Commit b2c0568c authored by Marin Jankovski's avatar Marin Jankovski

Add monit recipe

parent 5a488268
......@@ -3,3 +3,4 @@ site :opscode
metadata
cookbook 'magic_shell', git: 'git://github.com/customink-webops/magic_shell.git', ref: '447b4b67420d3a7a749d2dd3b13a7f9aceb54c36'
cookbook 'monit', git: 'git://github.com/phlipper/chef-monit.git', tag: '1.4.0'
......@@ -8,6 +8,11 @@
"git": "git://github.com/customink-webops/magic_shell.git",
"ref": "447b4b67420d3a7a749d2dd3b13a7f9aceb54c36"
},
"monit": {
"locked_version": "1.4.0",
"git": "git://github.com/phlipper/chef-monit.git",
"ref": "276c99ba08869ebd5117267d91a2ff6aa0d9fc6b"
},
"redisio": {
"locked_version": "1.7.0"
},
......@@ -30,7 +35,7 @@
"locked_version": "1.1.0"
},
"mysql": {
"locked_version": "2.1.2"
"locked_version": "4.0.6"
},
"database": {
"locked_version": "1.5.2"
......
......@@ -91,3 +91,7 @@ else
default['gitlab']['revision'] = "6-3-stable"
default['gitlab']['port'] = "80"
end
default['gitlab']['monitrc']['unicorn_pid_path'] = "#{default['gitlab']['path']}/tmp/pids/unicorn.pid"
default['gitlab']['monitrc']['sidekiq_pid_path'] = "#{default['gitlab']['path']}/tmp/pids/sidekiq.pid"
default['gitlab']['monitrc']['notify_email'] = "monitrc@localhost"
......@@ -8,7 +8,7 @@ version '0.6.3'
recipe "gitlab::default", "Installation"
%w{ redisio ruby_build postgresql mysql database postfix yum phantomjs magic_shell apt}.each do |dep|
%w{ redisio ruby_build postgresql mysql database postfix yum phantomjs magic_shell apt monit }.each do |dep|
depends dep
end
......
#
# Cookbook Name:: gitlab
# Recipe:: monit
#
monitrc = node['gitlab']['monitrc']
include_recipe "monit::default"
monit_monitrc "sidekiq" do
variables ({
sidekiq_pid_path: monitrc['sidekiq_pid_path'],
notify_email: monitrc['notify_email']
})
end
monit_monitrc "unicorn" do
variables ({
unicorn_pid_path: monitrc['unicorn_pid_path'],
notify_email: monitrc['notify_email']
})
end
check process gitlab_sidekiq with pidfile <%= @sidekiq_pid_path %>
alert <%= @notify_email %>
start program = "/bin/su - git -c 'RAILS_ENV=production /home/git/gitlab/script/background_jobs start'" with timeout 80 seconds
stop program = "/bin/su - git -c 'RAILS_ENV=production /home/git/gitlab/script/background_jobs stop'" with timeout 40 seconds
# Assuming our server has two cores, 40% totalcpu means pinning 80% of a single core
if totalcpu is greater than 40% for 10 cycles then restart
if totalmem is greater than 225 MB for 10 cycles then restart
if 5 restart within 5 cycles then alert
group gitlab_sidekiq
check program test_sidekiq_max_workers with path "<%= @app_home %>/bin/test_sidekiq_max_workers.sh"
alert <%= @notify_email %>
if status = 0 then exec "/usr/bin/monit restart gitlab_sidekiq"
check process unicorn with pidfile <%= @unicorn_pid_path %>
alert <%= @notify_email %> but not on { ppid }
start program = "/bin/cat /dev/null"
stop program = "/bin/su - git -c 'RAILS_ENV=production /home/git/gitlab/script/web reload'"
if totalmem is greater than 1000.0 MB for 25 cycles then restart
if cpu is greater than 80% for 50 cycles then restart
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment