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:
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
sudo apt-get install supervisor
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
[program:] command = stdout_logfile = stderr_logfile = logfile_maxbytes = 50MB ; optional logfile_backups = 10 ; needed if you want to rotate log files user = root ; user as which the script should be executed environment=variable1='value',variable2='value' ; environment variale to pass if any
Daemonizig the command:
supervisorctl reread supervisorctl update
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:
sudo supervisorctl stop sudo supervisorctl stop all
starting a process
sudo supervisorctl stop
restarting a process
sudo supervisorctl restart sudo supervisorctl restart all
Micropyramid is a software development and cloud consulting partner for enterprise businesses across the world. We work on python, Django, Salesforce, Angular, Reactjs, React Native, MySQL, PostgreSQL, Docker, Linux, Ansible, git, amazon web services. We are Amazon and salesforce consulting partner with 5 years of cloud architect experience. We develop e-commerce, retail, banking, machine learning, CMS, CRM web and mobile applications.
Django-CRM :Customer relationship management based on Django
Django-blog-it : django blog with complete customization and ready to use with one click installer Edit
Django-webpacker : A django compressor tool
Django-MFA : Multi Factor Authentication
Docker-box : Web Interface to manage full blown docker containers and imagesMore...