Module: Capistrano::MonitBase::Service
- Defined in:
- lib/capistrano/base_helper/monit_base.rb
Class Method Summary collapse
-
.command_monit(command, service_name = "", arguments = "") ⇒ Object
Command a single monit service.
- .disable(service_conf_filename) ⇒ Object
-
.enable(service_conf_filename) ⇒ Object
The service name is the same as the conf file name for the service.
Class Method Details
.command_monit(command, service_name = "", arguments = "") ⇒ Object
Command a single monit service
The service name scheme is recommended to be “#user_#application_#environment_#service”
191 192 193 194 195 |
# File 'lib/capistrano/base_helper/monit_base.rb', line 191 def command_monit(command, service_name="", arguments="") c = Capistrano::BaseHelper.get_capistrano_instance service_name = "#{c.fetch(:user)}_#{c.fetch(:application)}_#{c.fetch(:environment)}_#{c.fetch(:service)}" if service_name == "" c.run("#{c.sudo} monit #{arguments} #{command} #{service_name}") end |
.disable(service_conf_filename) ⇒ Object
208 209 210 211 |
# File 'lib/capistrano/base_helper/monit_base.rb', line 208 def disable(service_conf_filename) c = Capistrano::BaseHelper.get_capistrano_instance c.run("rm -f #{File.join(c.fetch(:monit_enabled_path), service_conf_filename)}") end |
.enable(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
203 204 205 206 |
# File 'lib/capistrano/base_helper/monit_base.rb', line 203 def enable(service_conf_filename) c = Capistrano::BaseHelper.get_capistrano_instance c.run("[ -h #{File.join(c.fetch(:monit_enabled_path), service_conf_filename)} ] || ln -sf #{File.join(c.fetch(:monit_available_path), service_conf_filename)} #{File.join(c.fetch(:monit_enabled_path), service_conf_filename)}") end |