# Issues with service module

**URL:** <https://forum.ansible.com/t/issues-with-service-module/11902>\
**Category:** Ansible Project\
**Tags:** ansible-project\
**Created:** [September 17, 2012, 12:54pm UTC](https://forum.ansible.com/t/issues-with-service-module/11902 "2012-09-17T12:54:52Z")\
**Posts on this page:** 5\
**Page:** 1

<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:** [September 17, 2012, 12:54pm UTC](https://forum.ansible.com/t/issues-with-service-module/11902/1 "2012-09-17T12:54:52Z")

</div>

> After some digging, it seems that the issue is related to the fact that I'm  
> backgrounding the process, which seems odd as should only use  
> service-command to start/stop the process(?)
> 
> The start function in the init-script looks like this:  
> daemon "/path/to/app/appname $OPTS \>/dev/null 2\>&1 &"

Having seen this before I suspect it's still not daemonizing correctly.

---

<div class="post-metadata">

**Author:** ![PJ1](https://avatars.discourse-cdn.com/v4/letter/p/eb8c5e/32.png) [@PJ1](https://forum.ansible.com/u/PJ1)\
**Post date:** [September 17, 2012, 2:02pm UTC](https://forum.ansible.com/t/issues-with-service-module/11902/2 "2012-09-17T14:02:48Z")

</div>

I installed and used daemonize which seems to have solved all problems for me.

---

<div class="post-metadata">

**Author:** ![Tim\_Bielawa](https://avatars.discourse-cdn.com/v4/letter/t/ed8c4c/32.png) [@Tim\_Bielawa](https://forum.ansible.com/u/Tim_Bielawa)\
**Post date:** [September 22, 2012, 1:07am UTC](https://forum.ansible.com/t/issues-with-service-module/11902/3 "2012-09-22T01:07:09Z")

</div>

Some of us were talking about an issue similar to this on IRC the  
other day regarding the RabbitMQ and JBossAS init scripts. The  
solution we came up with was:

action: command /bin/nohub /bin/service $foo start

Which is a functional, yet unsatisfying and hackish kludge.

I'm looking now at making something like this possible:

action: service nohup=True name=$foo ensure=started

"Try using the 'nohup' parameter when you have misbehaving init  
scripts which don't detach correctly"

---

<div class="post-metadata">

**Author:** ![PJ1](https://avatars.discourse-cdn.com/v4/letter/p/eb8c5e/32.png) [@PJ1](https://forum.ansible.com/u/PJ1)\
**Post date:** [September 22, 2012, 8:16am UTC](https://forum.ansible.com/t/issues-with-service-module/11902/4 "2012-09-22T08:16:15Z")

</div>

That would nohup the entire /sbin/service process which is most likely not preferable and could most likely lead to complications if unlucky.  
I will stick with daemonize as it’s designed to deal with applications that can’t do this themselves as also seems to be available in most distributions ([http://software.clapper.org/daemonize/](http://software.clapper.org/daemonize/)).

I simply added “/usr/sbin/daemonize -u app\_user /path/to/app/appname $OPTS” to my custom init-script to solve the problem.

---

<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:** [September 22, 2012, 12:39pm UTC](https://forum.ansible.com/t/issues-with-service-module/11902/5 "2012-09-22T12:39:14Z")

</div>

Inclined to agree
