# Monit configuration for SIDEKIQ : <%= fetch(:application) %> (<%= fetch(:stage) %>) <% processes_pids.each_with_index do |pid_file, idx| %> <% args = [] args.push "--index #{idx}" args.push "--pidfile #{pid_file}" args.push "--environment #{fetch(:sidekiq_env)}" args.push "--logfile #{fetch(:sidekiq_log)}" if fetch(:sidekiq_log) args.push "--require #{fetch(:sidekiq_require)}" if fetch(:sidekiq_require) args.push "--tag #{fetch(:sidekiq_tag)}" if fetch(:sidekiq_tag) if fetch(:sidekiq_special_queues) queue_config = sidekiq_special_config(idx) args.push "--queue #{ queue_config[:queue] || 'default' }" args.push "--concurrency #{ queue_config[:concurrency] || 7 }" else Array(fetch(:sidekiq_queue)).each do |queue| args.push "--queue #{queue}" end args.push "--concurrency #{fetch(:sidekiq_concurrency)}" if fetch(:sidekiq_concurrency) end args.push "--config #{fetch(:sidekiq_config)}" if fetch(:sidekiq_config) # use sidekiq_options for special options args.push fetch(:sidekiq_options) if fetch(:sidekiq_options) args.push '--daemon' %> check process <%= sidekiq_service_name(idx) %> with pidfile "<%= pid_file %>" start program = <%= monit_app_prefixed("sidekiq #{ args.join(" ") }") %> with timeout <%= fetch(:monit_sidekiq_timeout_sec, 90) %> seconds stop program = <%= monit_app_prefixed("sidekiqctl stop #{ pid_file }") %> with timeout <%= fetch(:monit_sidekiq_timeout_sec, 90) %> seconds group sidekiq-<%= fetch(:sidekiq_monit_group, fetch(:application)) %>-<%= fetch(:stage) %> # if does not exist then start # (default) if totalmem > <%= ( fetch( :monit_sidekiq_totalmem_mb, 300 ).to_i * 0.75 ).to_i %> MB then alert if totalmem > <%= fetch( :monit_sidekiq_totalmem_mb, 300 ) %> MB for 2 cycles then restart # if does not exist for 3 cycles then alert # alert <%= fetch(:monit_mail_to) %> only on { pid } if 3 restarts within 5 cycles then alert if 3 restarts within 5 cycles then timeout if 2 restarts within 3 cycles then alert if changed pid 2 times within 10 cycles then alert <% end %>