Module: Capistrano::Helpers::Runit
- Defined in:
- lib/capistrano/helpers/runit.rb
Instance Method Summary collapse
-
#control_service(service_name, command, arguments = '', _ignore_error = false) ⇒ Object
def restart_service(service_name) control_service(service_name, “restart”) end.
- #disable_service(service_name) ⇒ Object
- #enable_service(service_name) ⇒ Object
-
#force_control_service(service_name, command, arguments, _ignore_error = false) ⇒ Object
Will not check if the service exists before trying to force it down.
- #purge_service(service_name) ⇒ Object
-
#runit_app_services_control(command) ⇒ Object
Any command sent to this function controls all services related to the app.
-
#runit_set_executable_files(service_name) ⇒ Object
rubocop:disable Metrics/MethodLength, Metrics/AbcSize.
Instance Method Details
#control_service(service_name, command, arguments = '', _ignore_error = false) ⇒ Object
def restart_service(service_name)
control_service(service_name, "restart")
end
28 29 30 31 |
# File 'lib/capistrano/helpers/runit.rb', line 28 def control_service(service_name, command, arguments = '', _ignore_error = false) return unless test "[ -h '#{runit_service_path(service_name)}/run' ]" execute :sv, "#{arguments} #{command} #{runit_service_path(service_name)}" end |
#disable_service(service_name) ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/capistrano/helpers/runit.rb', line 38 def disable_service(service_name) begin force_control_service(service_name, 'force-stop', '', true) # force-stop the service before disabling it rescue end within(runit_service_path(service_name)) do execute :rm, '-f ./run' if test "[ -h '#{runit_service_run_file(service_name)}' ]" execute :rm, '-f ./finish' if test "[ -h '#{runit_service_finish_file(service_name)}' ]" end end |
#enable_service(service_name) ⇒ Object
49 50 51 52 53 54 |
# File 'lib/capistrano/helpers/runit.rb', line 49 def enable_service(service_name) within(runit_service_path(service_name)) do execute :ln, "-sf #{runit_service_run_config_file(service_name)} ./run" if test "[ ! -h '#{runit_service_run_file(service_name)}' ]" execute :ln, "-sf #{runit_service_finish_config_file(service_name)} ./finish" if test "[ ! -h '#{runit_service_finish_file(service_name)}' ]" end end |
#force_control_service(service_name, command, arguments, _ignore_error = false) ⇒ Object
Will not check if the service exists before trying to force it down
34 35 36 |
# File 'lib/capistrano/helpers/runit.rb', line 34 def force_control_service(service_name, command, arguments, _ignore_error = false) execute :sv, "#{arguments} #{command} #{runit_service_path(service_name)}" end |
#purge_service(service_name) ⇒ Object
56 57 58 |
# File 'lib/capistrano/helpers/runit.rb', line 56 def purge_service(service_name) execute :rm, "-rf #{runit_service_path(service_name)}" end |
#runit_app_services_control(command) ⇒ Object
Any command sent to this function controls all services related to the app
5 6 7 8 |
# File 'lib/capistrano/helpers/runit.rb', line 5 def runit_app_services_control(command) return unless test("[ -h '#{runit_etc_service_app_symlink_name}' ]") execute :sudo, :sv, "#{command} #{runit_etc_service_app_symlink_name}" end |
#runit_set_executable_files(service_name) ⇒ Object
rubocop:disable Metrics/MethodLength, Metrics/AbcSize
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/capistrano/helpers/runit.rb', line 60 def runit_set_executable_files(service_name) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize if test("[ -f '#{runit_service_run_config_file(service_name)}' ]") execute :chmod, "775 #{runit_service_run_config_file(service_name)}" end if test("[ -f '#{runit_service_finish_config_file(service_name)}' ]") execute :chmod, "775 #{runit_service_finish_config_file (service_name)}" end if test("[ -f '#{runit_service_log_run_file(service_name)}' ]") execute :chmod, "775 #{runit_service_log_run_file(service_name)}" end if test("[ -d '#{runit_service_control_path(service_name)}' ]") # rubocop:disable Style/GuardClause execute :chmod, "775 -R #{runit_service_control_path(service_name)}" end end |