Skip to content
This repository has been archived by the owner on Oct 15, 2019. It is now read-only.

Better way to stop supervisor service *if it exists* #59

Open
estebistec opened this issue Apr 15, 2014 · 2 comments
Open

Better way to stop supervisor service *if it exists* #59

estebistec opened this issue Apr 15, 2014 · 2 comments

Comments

@estebistec
Copy link

For a deploy I have, I'm looking to shut down a supervisord during the nodes upgrade because there are multiple nodes of this specific type. So I have HA and can do a "rolling upgrade" to avoid the currently upgrading server from serving requests with partially updated state.

The problem is that for a fully idempotent upgrade/install, I cannot assume that the service has even been created yet. So during the stop, it will blow up if the service doesn't exist.

Now, I can catch that exception and roll on, but the problem is that the exception is not typed, so I cannot be confident that the known exception is even what occurred as I allow it to happen while trying a stop. So...

  • Should there be a more specific exception type for this?
  • Is there a better way to try a stop where the service may not yet exist and am I just doing it wrong?
@jontrainor
Copy link

I stumbled on your question and have been wondering the same thing. This is how I handle the case where the service has not been created yet:

  supervisor_service someService do
    only_if { ::File.exists?("/etc/supervisor.d/" + someService + ".conf") }
    action :stop
  end

I would love to know if there is a better way though.

@whizz
Copy link

whizz commented Jun 29, 2015

In my opinion the correct way is to change the cookbook behavior and not to raise the error when attempting to stop a service that does not exist. It's idempotent, because since the service does not exist it's stopped by definition. I can submit a trivial one-line PR, if the author agrees that is a correct way to handle this. We have done this in our local version. Our use case is a bit different, but similar in result.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants