Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

In the following code, I create a service that I would like to start only after deploying files that it depends upon, and to restart it whenever those files change. This very basic recipe does not work as I'd expect:

supervisor_service "test-service" do
    command "/bin/cat"
    autostart false
    action :enable
end

cookbook_file "/tmp/test.txt" do
  source "test.txt"
  notifies :restart, 'supervisor_service[test-service]'
end

At the end of the run, chef-client only logs:

  • supervisor_service[test-service] action restart (up to date)

...and the service is not run. A manual sudo supervisorctl restart test-service works fine.

As far as I'm concerned a restart action is a request for the resource to change state (enabled -> started), what is the correct way to express this to Chef?

EDIT: I thought it would be worth adding that using the :immediately modifier causes the action to execute correctly. However in practice I have multiple files that may trigger a restart, and I need all of them to be updated before restarting (exactly the behaviour :delayed is meant to provide).

share|improve this question
    
has this been fixed in newer versions? I'm still having this problem. –  Pineapple Under the Sea Mar 18 at 6:19

1 Answer 1

I'm using Chef 10.14.4 and I get the same problems as you. What version are you using?

The notification does appear in the log file, as if it's about to run the :restart action on the supervisor_service provider:

INFO: cookbook_file[/tmp/test.txt] sending restart action to supervisor_service[test-service] (delayed)
INFO: Processing supervisor_service[test-service] action restart (temp::default line 16)

but then we simply get:

INFO: Chef Run complete in 14.302624 seconds

In the mean time, the best I could get working is:

supervisor_service "test-service" do
    command "/bin/cat"
    autostart false
    action :enable
end

execute "restart test-service" do
    command "supervisorctl restart test-service"
    user "root"
    action :nothing
end

cookbook_file "/tmp/test.txt" do
    source "test.txt"
    notifies :run, "execute[restart test-service]"
end

which is essentially the exact same code that is meant to run, but doesn't.

Since this works fine, but notifying the supervisor_service provider does not, one can only assume that a bug exists within this file in the supervisor cookbook (v0.4.0).

share|improve this answer
    
Chef 11.4 here. So the issue does not seem new... –  MattJ May 10 '13 at 10:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.