# stop and start an upstart service in a handler

**URL:** <https://forum.ansible.com/t/stop-and-start-an-upstart-service-in-a-handler/12632>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [April 5, 2013, 3:26pm UTC](https://forum.ansible.com/t/stop-and-start-an-upstart-service-in-a-handler/12632 "2013-04-05T15:26:54Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![seb.stark](https://avatars.discourse-cdn.com/v4/letter/s/e9c0ed/32.png) [@seb.stark](https://forum.ansible.com/u/seb.stark)\
**Post date:** [April 5, 2013, 3:26pm UTC](https://forum.ansible.com/t/stop-and-start-an-upstart-service-in-a-handler/12632/1 "2013-04-05T15:26:54Z")

</div>

With upstart, after you changed an option in /etc/init/.conf, it is not enough to run “restart ”. You would have to stop and start the service for the change to take effect, as documented in initctl(8) on Ubuntu 12.04.

How would I do so in an ansible handler? The following handler does not do it:

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [April 5, 2013, 3:41pm UTC](https://forum.ansible.com/t/stop-and-start-an-upstart-service-in-a-handler/12632/2 "2013-04-05T15:41:56Z")

</div>

What ansible version are you using?

ansible --version

---

<div class="post-metadata">

**Author:** ![seb.stark](https://avatars.discourse-cdn.com/v4/letter/s/e9c0ed/32.png) [@seb.stark](https://forum.ansible.com/u/seb.stark)\
**Post date:** [April 5, 2013, 3:46pm UTC](https://forum.ansible.com/t/stop-and-start-an-upstart-service-in-a-handler/12632/3 "2013-04-05T15:46:59Z")

</div>

ansible 1.1 from git tag release1.1

---

<div class="post-metadata">

**Author:** ![seb.stark](https://avatars.discourse-cdn.com/v4/letter/s/e9c0ed/32.png) [@seb.stark](https://forum.ansible.com/u/seb.stark)\
**Post date:** [April 5, 2013, 3:53pm UTC](https://forum.ansible.com/t/stop-and-start-an-upstart-service-in-a-handler/12632/4 "2013-04-05T15:53:44Z")

</div>

By the way, for now I’m using

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [April 5, 2013, 4:34pm UTC](https://forum.ansible.com/t/stop-and-start-an-upstart-service-in-a-handler/12632/5 "2013-04-05T16:34:26Z")

</div>

Could it be that just this one service does not support restart?

I am fine with doing start+stop, but it seems restart _is_ a command.

```auto

```

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [April 5, 2013, 4:57pm UTC](https://forum.ansible.com/t/stop-and-start-an-upstart-service-in-a-handler/12632/6 "2013-04-05T16:57:01Z")

</div>

restart IS part of upstart

---

<div class="post-metadata">

**Author:** ![Brian\_Coca1](https://avatars.discourse-cdn.com/v4/letter/b/278dde/32.png) [@Brian\_Coca1](https://forum.ansible.com/u/Brian_Coca1)\
**Post date:** [April 5, 2013, 4:59pm UTC](https://forum.ansible.com/t/stop-and-start-an-upstart-service-in-a-handler/12632/7 "2013-04-05T16:59:14Z")

</div>

Ah, nvmd, I see the issue.

upstart’s restart will restart the service with the original config (won’t reread) so if you are updating the config you NEED to issue a separate stop + start to get it restarted with the new config … dumb upstart!

---

<div class="post-metadata">

**Author:** ![Ashley\_Penney](https://avatars.discourse-cdn.com/v4/letter/a/48db29/32.png) [@Ashley\_Penney](https://forum.ansible.com/u/Ashley_Penney)\
**Post date:** [April 5, 2013, 4:59pm UTC](https://forum.ansible.com/t/stop-and-start-an-upstart-service-in-a-handler/12632/8 "2013-04-05T16:59:44Z")

</div>

Based on my reading of this he’s saying that restart is fine UNLESS you edit the actual upstart job itself and then restart doesn’t reload that off disk and see the changes. Is that accurate?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [April 5, 2013, 6:39pm UTC](https://forum.ansible.com/t/stop-and-start-an-upstart-service-in-a-handler/12632/9 "2013-04-05T18:39:57Z")

</div>

So the upstart config file got templated also? I concur, dumb upstart!

The SysV code does explicit stop/start somewhat for this reason.

I’m fine with patches to make it do the same.

---

<div class="post-metadata">

**Author:** ![seb.stark](https://avatars.discourse-cdn.com/v4/letter/s/e9c0ed/32.png) [@seb.stark](https://forum.ansible.com/u/seb.stark)\
**Post date:** [April 7, 2013, 2:08pm UTC](https://forum.ansible.com/t/stop-and-start-an-upstart-service-in-a-handler/12632/10 "2013-04-07T14:08:41Z")

</div>

Yes.

I think there is no room here to be smart and detect whichever method is needed, so let the user choose.

How about a userestart=yes/no option that defaults to no?

---

<div class="post-metadata">

**Author:** ![seb.stark](https://avatars.discourse-cdn.com/v4/letter/s/e9c0ed/32.png) [@seb.stark](https://forum.ansible.com/u/seb.stark)\
**Post date:** [April 7, 2013, 2:18pm UTC](https://forum.ansible.com/t/stop-and-start-an-upstart-service-in-a-handler/12632/11 "2013-04-07T14:18:36Z")

</div>

Yes. Seems upstart does not meet many people’s expectations here.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [April 7, 2013, 3:41pm UTC](https://forum.ansible.com/t/stop-and-start-an-upstart-service-in-a-handler/12632/12 "2013-04-07T15:41:13Z")

</div>

At this point feels like restart\_mode as httpd may like “graceful” as well.

– Michael
