Daemonizing any command with SUPERVISOR

Demonizing a command means to make it run as a background process.

so when we have a command that we want to daemonize there are many ways to do it, most common methods are:

  1. using upstart
  2. adding it to /etc/rc.local
  3. creating a script in /etc/init.d and adding them to runlevel folders manually (i.e. incase you want to start, stop a command)

Most easiest seems to be using supervisor

Installing Supervisor and sample configuration file:

installing it in ubuntu or any Debian based system is as simple as

now you can create your configurations in /etc/supervisor/conf.d/ folder with extension “.conf”

a simple configuration file at /etc/supervisor/conf.d/test-program.conf will look as

Daemonizig the command:

The first command re-reads the configuration files and detects any changes

The second command updates the supervisor process with the new or changed configurations.

Now you have daemonized the command as background process

Other useful commands:

Stopping a process:

starting a process

restarting a process

--

--

Python, Django, Android and IOS, reactjs, react-native, AWS, Salesforce consulting & development company

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
MicroPyramid

Python, Django, Android and IOS, reactjs, react-native, AWS, Salesforce consulting & development company