# Run a blocking node.js server script in the background through ansible

**URL:** <https://forum.ansible.com/t/run-a-blocking-node-js-server-script-in-the-background-through-ansible/14268>\
**Category:** Ansible Project\
**Created:** [January 4, 2014, 9:17pm UTC](https://forum.ansible.com/t/run-a-blocking-node-js-server-script-in-the-background-through-ansible/14268 "2014-01-04T21:17:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jacob\_Lyles](https://avatars.discourse-cdn.com/v4/letter/j/c6cbf5/32.png) [@Jacob\_Lyles](https://forum.ansible.com/u/Jacob_Lyles)\
**Post date:** [January 4, 2014, 9:17pm UTC](https://forum.ansible.com/t/run-a-blocking-node-js-server-script-in-the-background-through-ansible/14268/1 "2014-01-04T21:17:04Z")

</div>

Hi there,

I’m trying to do something with ansible that sounds easy/common enough. Somewhere in my playbook, after setting up my reverse proxies, static directories, and mysql, I’d like to kick off my node.js app. The typical way I would do this manually is by running:

npm start &

“npm start” runs server.js, which starts my server. The ampersand runs everything in the background.

However, it appears that the “&” doesn’t work for ansible. The playbook pauses at this point and never returns. How do I run a blocking script with ansible?

Thanks,  
Jacob

---

<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:** [January 4, 2014, 10:36pm UTC](https://forum.ansible.com/t/run-a-blocking-node-js-server-script-in-the-background-through-ansible/14268/2 "2014-01-04T22:36:07Z")

</div>

Well, generally I’d expect you would _NOT_ want to run these kinds of things through the login shell and would have a proper init script, or configure something akin to supervisor. What happens if you reboot your server? Etc? You’d want something there to restart it.

What you are experiencing is a script that is failing to daemonize properly.

Should you want to background a task though, you can do it as follows:

[http://docs.ansible.com/playbooks\_async.html](http://docs.ansible.com/playbooks_async.html)
