I've written a script which I trigger as a service. When I call service myservice start the service starts fine. However, when the same service is triggered using chef, the service doesnt start. My chef service code looks like this

service "myservice" do
 supports :status => true, :restart => true, :reload => true
 action [ :enable, :start ]

I call the script using knife bootstrap <ip> -r 'recipe[testservice]'. What am I missing here? Thanks for the help!

  • Could you say what platform you are running this on? And what chef version? The service provider might have something to do with it. – Oin Apr 4 '13 at 15:03
  • I use a Centos box. The chef version is 11.4.0. – Jay Apr 4 '13 at 15:46
  • In the output from knife bootstrap do you see a line with: INFO: service[myservice] restarted ? – Oin Apr 4 '13 at 15:52
  • I see this service[myservice] action start (up to date) – Jay Apr 4 '13 at 16:23
  • for some reason chef thinks my service is running when its not. – Jay Apr 4 '13 at 16:23

Most probably you have some errors in your /etc/init.d/myservice script. When you say that yourservice supports status command, chef will run service myservice status and check the exitcode. If it's 0, it assumes that the service is running. Your script should exit with nonzero code.


When Chef starts a service it first checks if the service is already running ("/sbin/service myservice status" on CentOS). If it determines that it is running already it won't do the start, or log anything at higher than debug level:



I was facing the same issue, actually the chef 11 server relies on the action :status to start the service. Hence like action start and stop in your script you would also require action status, Which shall return the current status of the script.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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