Skip to content

Commit

Permalink
Update helper methods for servie commands
Browse files Browse the repository at this point in the history
Signed-off-by: Balasankar "Balu" C <balasankar@gitlab.com>
  • Loading branch information
balasankarc committed May 8, 2020
1 parent 355105b commit 938d86e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions libraries/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def runit_send_signal(signal, friendly_name = nil)
end

def running?
cmd = safe_sv_shellout("#{sv_args}status #{service_dir_name}", returns: [0, 100])
cmd = safe_sv_shellout("#{sv_args}#{new_resource.status_command} #{service_dir_name}", returns: [0, 100])
!cmd.error? && cmd.stdout =~ /^run:/
end

Expand Down Expand Up @@ -153,15 +153,15 @@ def disable_service
end

def start_service
safe_sv_shellout!("#{sv_args}start #{service_dir_name}")
safe_sv_shellout!("#{sv_args}#{new_resource.start_command} #{service_dir_name}")
end

def stop_service
safe_sv_shellout!("#{sv_args}stop #{service_dir_name}")
safe_sv_shellout!("#{sv_args}#{new_resource.stop_command} #{service_dir_name}")
end

def restart_service
safe_sv_shellout!("#{sv_args}restart #{service_dir_name}")
safe_sv_shellout!("#{sv_args}#{new_resource.restart_command} #{service_dir_name}")
end

def restart_log_service
Expand Down
6 changes: 3 additions & 3 deletions libraries/resource_runit_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ class RunitService < Chef::Resource::Service
property :check_script_template_name, String, default: lazy { service_name }
property :finish_script_template_name, String, default: lazy { service_name }
property :control_template_names, Hash, default: lazy { set_control_template_names }
property :status_command, String, default: lazy { "#{sv_bin} status #{service_name}" }
property :start_command, String, default: 'start'
property :stop_command, String, default: 'stop'
property :restart_command, String, default: 'restart'
property :status_command, String, default: 'status'
property :sv_templates, [true, false], default: true
property :sv_timeout, Integer
property :sv_verbose, [TrueClass, FalseClass], default: false
property :sv_verbose, [true, false], default: false
property :log_dir, String, default: lazy { ::File.join('/var/log/', service_name) }
property :log_flags, String, default: '-tt'
property :log_size, Integer
Expand Down Expand Up @@ -103,10 +103,10 @@ def after_created
find_resource(:service, new_resource.name) do # creates if it does not exist
provider Chef::Provider::Service::Simple
supports new_resource.supports
status_command new_resource.status_command
start_command "#{new_resource.sv_bin} #{new_resource.start_command} #{service_dir_name}"
stop_command "#{new_resource.sv_bin} #{new_resource.stop_command} #{service_dir_name}"
restart_command "#{new_resource.sv_bin} #{new_resource.restart_command} #{service_dir_name}"
status_command "#{new_resource.sv_bin} #{new_resource.status_command} #{service_dir_name}"
action :nothing
end
end
Expand Down

0 comments on commit 938d86e

Please sign in to comment.