# Restarting nodejs application within Docker container

**URL:** <https://forums.balena.io/t/restarting-nodejs-application-within-docker-container/57>\
**Category:** Product support\
**Created:** [June 1, 2015, 12:04pm UTC](https://forums.balena.io/t/restarting-nodejs-application-within-docker-container/57 "2015-06-01T12:04:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![RobinReumers](https://avatars.discourse-cdn.com/v4/letter/r/d78d45/32.png) [@RobinReumers](https://forums.balena.io/u/RobinReumers)\
**Post date:** [June 1, 2015, 12:04pm UTC](https://forums.balena.io/t/restarting-nodejs-application-within-docker-container/57/1 "2015-06-01T12:04:24Z")

</div>

Hi, I’d like to have the ability to restart the nodejs application, if it ever crashed. Something like monit, but then using Docker/Resin.io. Do you support this feature?

---

<div class="post-metadata">

**Author:** ![craig-mulligan](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/craig-mulligan/32/18_2.png) [@craig-mulligan](https://forums.balena.io/u/craig-mulligan)\
**Post date:** [June 1, 2015, 10:09pm UTC](https://forums.balena.io/t/restarting-nodejs-application-within-docker-container/57/2 "2015-06-01T22:09:42Z")

</div>

Hey Robin,

Do you mean an automatic restart of a container if your main process crashes? We currently only support a manual restart, if you go to your application dashboard’s actions tab you’ll see a restart button. (see screen shot) However this will restart the containers across all the devices associated with that application.

![](https://sea2.discourse-cdn.com/balena/uploads/balena/33/4bd6b725a816b7fe.png)

You could also update a per device environment variable which would only restart that devices container.

Cheers,  
Craig

---

<div class="post-metadata">

**Author:** ![RobinReumers](https://avatars.discourse-cdn.com/v4/letter/r/d78d45/32.png) [@RobinReumers](https://forums.balena.io/u/RobinReumers)\
**Post date:** [June 2, 2015, 8:08am UTC](https://forums.balena.io/t/restarting-nodejs-application-within-docker-container/57/3 "2015-06-02T08:08:32Z")

</div>

Thanks Craig, that helps a lot. But I was indeed talking about my main process crashing on just one device. Ideally there should be a trigger that could restart it. Technically [resin.io](http://resin.io) already knows when the process stopped (log will say “Application Stopped”), so it should be quite easy to integrate an auto-restart feature, right?

Either way, such a feature would be really nice to have.

---

<div class="post-metadata">

**Author:** ![craig-mulligan](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/craig-mulligan/32/18_2.png) [@craig-mulligan](https://forums.balena.io/u/craig-mulligan)\
**Post date:** [June 2, 2015, 4:42pm UTC](https://forums.balena.io/t/restarting-nodejs-application-within-docker-container/57/4 "2015-06-02T16:42:29Z")

</div>

Hey,

Its definitely in the roadmap but it’s still a while off. Our new images, which we will be released this week, will keep your container open and running even if you scripts throws an error. Meaning that you could run a monitoring service like mmonit.

Left me know if you need any help with implementation. 😄

---

<div class="post-metadata">

**Author:** ![RobinReumers](https://avatars.discourse-cdn.com/v4/letter/r/d78d45/32.png) [@RobinReumers](https://forums.balena.io/u/RobinReumers)\
**Post date:** [June 2, 2015, 6:35pm UTC](https://forums.balena.io/t/restarting-nodejs-application-within-docker-container/57/5 "2015-06-02T18:35:34Z")

</div>

Ok perfect, thanks Craig.

---

<div class="post-metadata">

**Author:** ![craig-mulligan](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/craig-mulligan/32/18_2.png) [@craig-mulligan](https://forums.balena.io/u/craig-mulligan)\
**Post date:** [June 12, 2015, 1:30pm UTC](https://forums.balena.io/t/restarting-nodejs-application-within-docker-container/57/6 "2015-06-12T13:30:04Z")

</div>

Hey Robin,

Your question encouraged me to play around with node process manager (pm2) on a resin device. It maybe of interest if you haven’t already solved the problem.

You can read about it [here](https://resin.io/blog/eternal-applications-with-pm2-and-resin-io/)

Cheers,  
Craig
