3 ms·
The thing is, I don't run my applications locally with a "local run command". I prefer to have a local system set up just like the production server, but in a
by mg 3y ago
The thing is, I don't run my applications locally with a "local run command".
I prefer to have a local system set up just like the production server, but in a container.
Maybe using WSGI with MaxConnectionsPerChild=1 could be a solution? But that would start a new (for example) Django instance for every request. Not sure how fast Django starts.
Another option might be to send a HUP signal to Apache:
apachectl -k restart
That will only kill the worker threats. And when there are none (because another file save triggered it already), this operation might be almost free in terms of resource usage. This also would require WSGI or similar. Not sure if that is the standard approach for Django+Apache.
- deleted 3y ago[deleted]
- onetoo 3y agoI would still recommend running it properly locally, but whatever. Pseudo-devcontainer it is. I assume the code is properly volume mounted. In production, you would want to run your app through gunicorn/uvicorn/whatever on an internal-only port, and reverse-proxy to it with a public-facing apache or similar. Set up apache to reverse proxy like you would on prod, and run gunicorn/uvicorn l/whatever like you would on prod, except you also add the autoreload flag. E.g. uvicorn main:app --host 0.0.0.0 --port 12345 --reload If production uses containers, you should keep the python image slim and simple, including only gunicorn/uvicorn and have the reverse proxy in another container. Etc.
- traverseda 3y agoIs the problem you're having that you feel the need to expose a WSGI/ASGI interface instead of just a reverse proxy? Take a look at gunicorn, and for static files server you can use whitenoise. With those two you can just stand up an python program in a container that serves html, and put it behind whatever reverse proxy you want.