Supervisor & Daphne Configuration¶
Last Updated: September 2022
Supervisor is used to manage the NGINX and Daphne processes. As an ASGI server, Daphne is able to be run with multiple worker processes. It would be cumbersome to manage them individually. Using Supervisor, you will be able to use one command to start, stop, or restart the NGINX process and all of the Daphne processes.
1. Generate the Supervisor Configuration Files¶
One configuration file will be needed for NGINX and another for Daphne. Use the
tethys gen command to generate default versions of these configuration files:
tethys gen nginx_service --overwrite tethys gen asgi_service --overwrite
2. Review Supervisor Configuration Files¶
Review the contents of the NGINX configuration file:
In particular, the locations of the log files. These may be useful for debugging later on.
Review the contents of the Daphne (ASGI) configuration file:
In particular, verify the following:
TETHYS_HOMEvariable is set correctly
directoryis the path to the directory where Tethys Platform is installed (usually the
site-packagesdirectory of your
numprocsto the number of Daphne processes you would like it to run.
Note the location of the
Note the location of the process file after the
-uargument of the daphne command in the
commandparameter. The default value for the process file should be something like:
<TETHYS_HOME> with the path to the Tethys home directory as noted in Portal Configuration section.
3. Create Run Directory¶
Verify that the directory where the ASGI process files will be created exists. You noted this directory when verifying the
asgi_supervisor.conf file in the previous step. For example, if the path in
asgi_supervisor.conf was defined as
/run/asgi/tethys_asgi%(process_num)d.sock, then you would need to ensure that the
/run/asgi directory exists and is owned by the
If the process file is specified to be created at the root
/run directory (e.g.:
/run/tethys_asgi%(process_num)d.sock), then no action is required for this step.
supervisord.conf (CentOS Only)¶
For CentOS systems, modify
supervisord.conf to recognize our configuration files:
CentOS:sudo sed -i '$ s@$@ /etc/supervisord.d/*.conf@' "/etc/supervisord.conf"
6. Setup Tethys Log¶
Create the log file in the location where supervisor expects it to be (see last item in 2.2).
Create a directory and file for Daphne/Django to write the Tethys Portal logs:
sudo mkdir -p /var/log/tethys sudo touch /var/log/tethys/tethys.log
Change the directory to be owned by the NGINX user:
sudo chown -R <NGINX_USER> /var/log/tethys
<NGINX_USER>with the name of the user noted in the NGINX Configuration.
7. Reload the Configuration¶
Once you have finished the configuration steps, it is necessary to instruct Supervisor to reread and update as follows so that it loads our new Supervisor configurations:
sudo supervisorctl reread sudo supervisorctl update
This step needs to be performed anytime you make changes to the