Skip to content
This repository has been archived by the owner on Oct 15, 2019. It is now read-only.

Add action reread #89

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions providers/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
end
end

action :reread do
converge_by("Re-reading #{ new_resource }") do
reread_service
end
end

action :disable do
if current_resource.state == 'UNAVAILABLE'
Chef::Log.info "#{new_resource} is already disabled."
Expand Down Expand Up @@ -105,6 +111,30 @@ def enable_service
end
end

def reread_service
e = execute "supervisorctl reread" do
action :nothing
user "root"
end

t = template "#{node['supervisor']['dir']}/#{new_resource.service_name}.conf" do
source "program.conf.erb"
cookbook "supervisor"
owner "root"
group "root"
mode "644"
variables :prog => new_resource
Chef::Log.info "supervisorctl reread [#{new_resource.service_name}] "
notifies :run, "execute[supervisorctl reread]", :immediately
end

t.run_action(:create)
if t.updated?
e.run_action(:run)
end

end

def disable_service
execute "supervisorctl update" do
action :nothing
Expand Down
2 changes: 1 addition & 1 deletion resources/service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# limitations under the License.
#

actions :enable, :disable, :start, :stop, :restart
actions :enable, :disable, :start, :stop, :restart, :reread
default_action :enable

attribute :service_name, :kind_of => String, :name_attribute => true
Expand Down