Run startup code in the parent with Django and Gunicorn

我与影子孤独终老i 提交于 2019-12-06 01:01:01

I have just run into this problem myself, and the solution was to basically chain the commands to guarantee execution and correct order:

Script started by systemd, supervisord or any other such system:

#!/bin/sh
python manage.py my_custom_command && gunicorn project.wsgi $@

Create your own custom django command and off you go. You can get some speedups if you disable sanity checks in the command (requires_system_checks and requires_migrations_checks set to False).

To make things more generic, you could create a "boot" signal to which you connect arbitrary functions, and just emit the signal from this custom command.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!