# supervisorctl task: why does state=restarted error out if it isn't running?

**URL:** <https://forum.ansible.com/t/supervisorctl-task-why-does-state-restarted-error-out-if-it-isnt-running/12373>\
**Category:** Ansible Project\
**Created:** [February 17, 2013, 12:29am UTC](https://forum.ansible.com/t/supervisorctl-task-why-does-state-restarted-error-out-if-it-isnt-running/12373 "2013-02-17T00:29:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Scott\_Anderson](https://avatars.discourse-cdn.com/v4/letter/s/ed655f/32.png) [@Scott\_Anderson](https://forum.ansible.com/u/Scott_Anderson)\
**Post date:** [February 17, 2013, 12:29am UTC](https://forum.ansible.com/t/supervisorctl-task-why-does-state-restarted-error-out-if-it-isnt-running/12373/1 "2013-02-17T00:29:25Z")

</div>

These lines of codes caused me a lot of angst earlier today:

elif not running and state == ‘restarted’:  
module.fail\_json(msg=‘Could not restart `%s` because it is not running’ % name)

I’m curious as to why this decision was made. To my mind, “restart” means “restart if it’s already running, otherwise start it”. It’s the sort of thing you run as a notify after a config change or code change. In my opinion it shouldn’t care if the process isn’t already started, because the first time a deploy is run after a new server install the task won’t be running.

To workaround this I have to explicitly stop the app, then start the app. Not a huge deal but it isn’t what I expected at all. Is it a philosophical thing?

Regards,  
-scott

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [February 17, 2013, 12:50am UTC](https://forum.ansible.com/t/supervisorctl-task-why-does-state-restarted-error-out-if-it-isnt-running/12373/2 "2013-02-17T00:50:16Z")

</div>

I agree, it's a bug.

Please submit a pull request to fix it or file a bug.

I don't use supervisorctl, so it would be nice if someone who does  
could fit it and test.

---

<div class="post-metadata">

**Author:** ![Scott\_Anderson](https://avatars.discourse-cdn.com/v4/letter/s/ed655f/32.png) [@Scott\_Anderson](https://forum.ansible.com/u/Scott_Anderson)\
**Post date:** [February 17, 2013, 1:42am UTC](https://forum.ansible.com/t/supervisorctl-task-why-does-state-restarted-error-out-if-it-isnt-running/12373/3 "2013-02-17T01:42:50Z")

</div>

I will do so.

-scott
