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