0

Control Node.Js server using upstart/monit

Environment: debian/ubuntu

This script can monitor cpu/memory usage of your node application, and start/stop it via a web interface or command line

Step 1. install startup and monit (they are normally preinstalled in ubuntu)

then edit /etc/defaults/monit, set startup=1

Step 2. in /etc/init/, create a config of your application, ex: your_app.conf with code

NOTICE:

  • user:usergroup must be the one who owns Node
  • modify the log folder as you wish
  • in order to use relative paths in Node, we must change directory to project's folder

Step 3. edit file /etc/monit/monitrc, enable web interface

Step 4. create file /etc/monit/conf.d/your_app.monitrc

NOTICE:

  • modify your_app as you wish
  • modify server port as you wish
  • monit will try to reach localhost:8080/valid_url to check the server status, so make sure your valid_url is valid 🙂

Step 5. now you can control your app. via web interface: localhost:2812 or via command:

NOTICE:

  • if your app. stopped, monit will restart it automatically.

Darktalker

Leave a Reply