Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix how service actions are invoked. #200

Merged
merged 2 commits into from
Oct 24, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 32 additions & 9 deletions providers/container.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,41 +16,47 @@ def load_current_resource
end

action :commit do
@service = service_action(:nothing) if service?
if exists?
commit
new_resource.updated_by_last_action(true)
end
end

action :cp do
@service = service_action(:nothing) if service?
if exists?
cp
new_resource.updated_by_last_action(true)
end
end

action :export do
@service = service_action(:nothing) if service?
if exists?
export
new_resource.updated_by_last_action(true)
end
end

action :kill do
@service = service_action(:nothing) if service?
if running?
kill
new_resource.updated_by_last_action(true)
end
end

action :redeploy do
@service = service_action(:nothing) if service?
stop if running?
remove_container if exists?
run
new_resource.updated_by_last_action(true)
end

action :remove do
@service = service_action(:nothing) if service?
if running?
stop
new_resource.updated_by_last_action(true)
Expand All @@ -62,21 +68,25 @@ def load_current_resource
end

action :remove_link do
@service = service_action(:nothing) if service?
new_resource.updated_by_last_action(remove_link)
end

action :remove_volume do
@service = service_action(:nothing) if service?
new_resource.updated_by_last_action(remove_volume)
end

action :restart do
@service = service_action(:nothing) if service?
if exists?
restart
new_resource.updated_by_last_action(true)
end
end

action :run do
@service = service_action(:nothing) if service?
unless running?
if exists?
start
Expand All @@ -88,20 +98,23 @@ def load_current_resource
end

action :start do
@service = service_action(:nothing) if service?
unless running?
start
new_resource.updated_by_last_action(true)
end
end

action :stop do
@service = service_action(:nothing) if service?
if running?
stop
new_resource.updated_by_last_action(true)
end
end

action :wait do
@service = service_action(:nothing) if service?
if running?
wait
new_resource.updated_by_last_action(true)
Expand Down Expand Up @@ -441,7 +454,7 @@ def service_create_systemd
)
end

service_action([:start, :enable])
service_start_and_enable
end

def service_create_sysv
Expand All @@ -457,7 +470,7 @@ def service_create_sysv
)
end

service_action([:start, :enable])
service_start_and_enable
end

def service_create_upstart
Expand All @@ -476,7 +489,7 @@ def service_create_upstart
)
end

service_action([:start, :enable])
service_start_and_enable
end

def service_name
Expand All @@ -503,7 +516,7 @@ def service_remove_runit
end

def service_remove_systemd
service_action([:stop, :disable])
service_stop_and_disable

%w(service socket).each do |f|
file "/usr/lib/systemd/system/#{service_name}.#{f}" do
Expand All @@ -513,31 +526,41 @@ def service_remove_systemd
end

def service_remove_sysv
service_action([:stop, :disable])
service_stop_and_disable

file "/etc/init.d/#{service_name}" do
action :delete
end
end

def service_remove_upstart
service_action([:stop, :disable])
service_stop_and_disable

file "/etc/init/#{service_name}" do
action :delete
end
end

def service_restart
service_action([:restart])
@service.run_action(:restart)
end

def service_start
service_action([:start])
@service.run_action(:start)
end

def service_stop
service_action([:stop])
@service.run_action(:stop)
end

def service_start_and_enable
@service.run_action(:start)
@service.run_action(:enable)
end

def service_stop_and_disable
@service.run_action(:stop)
@service.run_action(:disable)
end

def service_template
Expand Down