I am running a django webserver with default manage.py file, how can i daemonize it using svc daemontools
Content of my run file in daemontools is
#!/bin/bash
exec setuidgid <myuser> /usr/bin/python <path/to/manage.py> runserver 2>&1
Content of manage.py
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE","settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
The child process(manage.py runserver) of svscanboot forks off another process in execute_from_command_line (imported from django.core.management) function, which cannot be controlled through svc commands. Below is the process tree for svscanboot.
/bin/sh /usr/bin/svscanboot
\_ svscan /etc/service
\_ supervise myapp
\_ /usr/bin/python </path/to/manage.py> runserver
\_ /usr/bin/python </path/to/manage.py> runserver
Now if i execute svc -d it sends the TERM signal to the first runserver process, and as a result just that gets killed and the second process becomes an orphan process which cannot be controlled through svc commands.
So how do i control the entire process tree of the child process using daemontools?