module Capistrano::Helpers::Monit

Helper functions for monit

Public Instance Methods

command_monit(command, arguments = '') click to toggle source

Control / Command monit with given arguments

# File lib/capistrano/helpers/monit.rb, line 9
def command_monit(command, arguments = '')
  execute :sudo, :monit, "#{arguments} #{command}"
end
command_monit_group(command, arguments = '') click to toggle source

Control / Command a monit group namescheme: user_application_environment “#{user}_#{application}_#{environment}”

# File lib/capistrano/helpers/monit.rb, line 17
def command_monit_group(command, arguments = '')
  command_monit(command, "-g #{fetch(:monit_application_group_name)} #{arguments}")
end
command_monit_service(command, service_name, arguments = '') click to toggle source

Command a single monit service

The service name scheme is recommended to be “#{user}_#{application}_#{environment}_#{service}”

# File lib/capistrano/helpers/monit.rb, line 27
def command_monit_service(command, service_name, arguments = '')
  execute :sudo, :monit, "#{arguments} #{command} #{service_name}"
end
disable_monitor(service_conf_filename) click to toggle source
# File lib/capistrano/helpers/monit.rb, line 42
def disable_monitor(service_conf_filename)
  execute :rm, "-f #{File.join(fetch(:monit_enabled_path), service_conf_filename)}"
end
enable_monitor(service_conf_filename) click to toggle source

The service name is the same as the conf file name for the service. E.g. puma.conf

This will symlink the service to enabled service, but not start or reload monit configuration

# File lib/capistrano/helpers/monit.rb, line 37
def enable_monitor(service_conf_filename)
  return unless test("[ ! -h #{File.join(fetch(:monit_enabled_path), service_conf_filename)} ]")
  execute :ln, "-sf #{File.join(fetch(:monit_available_path), service_conf_filename)} #{File.join(fetch(:monit_enabled_path), service_conf_filename)}" # rubocop:disable Metrics/LineLength:
end