Commit 58ddd0c5 authored by Marin Jankovski's avatar Marin Jankovski

Changes to the monit recipe.

parent e873440e
......@@ -14,7 +14,7 @@ else
end
default['gitlab']['packages'] = packages
default['gitlab']['ruby'] = "2.1.1"
default['gitlab']['ruby'] = "2.0.0-p451"
# GitLab shell
default['gitlab']['shell_repository'] = "https://github.com/gitlabhq/gitlab-shell.git"
......@@ -207,4 +207,12 @@ default['gitlab']['monitrc']['unicorn'] = {
:mem_threshold => "1000.0", # in MB
:mem_cycles_number => "25"
}
default['gitlab']['monitrc']['notify_email'] = "monitrc@localhost"
default['gitlab']['monitrc']['disk_usage'] = {
:disk_percentage => "85", # in %, 0 to disable this config
:path => "/" # Path on the filesystem to monitor
}
# Can be specified if you need to use different alert email in sidekiq monitor config
# If you need only one alert email, specify with https://github.com/phlipper/chef-monit/blob/1.4.0/attributes/default.rb#L27
default['gitlab']['monitrc']['notify_email'] = nil
......@@ -25,6 +25,11 @@ monit_monitrc "sidekiq" do
})
end
file "/usr/local/bin/sidekiq_load_ok" do
content "#!/bin/sh\nexec $(dirname $0)/background_jobs load_ok\n"
mode 0755
end
unicorn = monitrc['unicorn']
monit_monitrc "unicorn" do
variables ({
......@@ -37,6 +42,16 @@ monit_monitrc "unicorn" do
})
end
disk_usage = monitrc['disk_usage']
if disk_usage['disk_percentage'] != "0"
monit_monitrc "disk_usage" do
variables ({
disk_percentage: disk_usage['disk_percentage'],
path: disk_usage['path']
})
end
end
directory "#{gitlab['path']}/bin" do
user gitlab['user']
group gitlab['group']
......
check filesystem fs with path <%= @path %>
if space usage > <%= @disk_percentage %>% then alert
check process gitlab_sidekiq with pidfile <%= @sidekiq_pid_path %>
<% if @notify_email%>
alert <%= @notify_email %>
<% end %>
start program = "/bin/su - <%= @gitlab_user %> -c 'RAILS_ENV=production <%= @gitlab_path %>/script/background_jobs start'" with timeout <%= @start_timeout %> seconds
stop program = "/bin/su - <%= @gitlab_user %> -c 'RAILS_ENV=production <%= @gitlab_path %>/script/background_jobs stop'" with timeout <%= @stop_timeout %> seconds
# Assuming our server has two cores, 40% totalcpu means pinning 80% of a single core
......@@ -7,3 +9,6 @@ check process gitlab_sidekiq with pidfile <%= @sidekiq_pid_path %>
if totalmem is greater than <%= @mem_threshold %> MB for <%= @mem_cycles_number %> cycles then restart
if <%= @restart_number %> restart within <%= @restart_cycles_number %> cycles then alert
group gitlab_sidekiq
check program sidekiq_load_ok with path "/usr/local/bin/sidekiq_load_ok"
if status != 0 then exec "/usr/bin/monit restart gitlab_sidekiq"
check process unicorn with pidfile <%= @unicorn_pid_path %>
<% if @notify_email %>
alert <%= @notify_email %> but not on { ppid }
<% end %>
start program = "/bin/cat /dev/null"
stop program = "/bin/su - <%= @gitlab_user %> -c 'RAILS_ENV=production <%= @gitlab_path %>/script/web reload'"
if totalmem is greater than <%= @mem_threshold %> MB for <%= @mem_cycles_number %> 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