4

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).

1
  • has this been fixed in newer versions? I'm still having this problem. Commented Mar 18, 2014 at 6:19

1 Answer 1

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).

1
  • Chef 11.4 here. So the issue does not seem new... Commented May 10, 2013 at 10:13

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.