0

I have a custom upstart service which I'm trying to automate via Chef. The chef flow is like this: - Create /etc/init/myservice.conf, notify restart myservice (if conf file changes) - Start myservice

The Chef service restart is actually carried out as /sbin/stop and /sbin/start So, if my service isn't already running, the restart fails saying that /sbin/stop myservice returned 1

Is there a way I can return 0 on /sbin/stop myservice if the service is already in a stopped state?

0

I had the same issue with tomcat and chef, use this:

/sbin/status tomcat_7 | grep -q "stop/waiting" || /sbin/stop tomcat_7

For start:

/sbin/status tomcat_7 | grep -q "start/running" || /sbin/start tomcat_7

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.