Module: Capistrano::Helpers::Monit
- Defined in:
- lib/capistrano/helpers/monit.rb
Overview
Helper functions for monit
Instance Method Summary collapse
-
#command_monit(command, arguments = '') ⇒ Object
Control / Command monit with given arguments.
-
#command_monit_group(command, arguments = '') ⇒ Object
Control / Command a monit group namescheme: user_application_environment “#user_#application_#environment”.
-
#command_monit_service(command, service_name, arguments = '') ⇒ Object
Command a single monit service.
- #disable_monitor(service_conf_filename) ⇒ Object
-
#enable_monitor(service_conf_filename) ⇒ Object
The service name is the same as the conf file name for the service.
Instance Method Details
#command_monit(command, arguments = '') ⇒ Object
Control / Command monit with given arguments
9 10 11 |
# File 'lib/capistrano/helpers/monit.rb', line 9 def command_monit(command, arguments = '') execute :sudo, :monit, "#{arguments} #{command}" end |
#command_monit_group(command, arguments = '') ⇒ Object
Control / Command a monit group namescheme: user_application_environment “#user_#application_#environment”
17 18 19 |
# 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 = '') ⇒ Object
Command a single monit service
The service name scheme is recommended to be “#user_#application_#environment_#service”
27 28 29 |
# 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) ⇒ Object
42 43 44 |
# 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) ⇒ Object
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
37 38 39 40 |
# 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 |