Update uwsgi and nginx changes without restart service

Question!


I`m thinking on making an django app who will dynamic add new django websites and static websites.
I can make all the steps , but the problem is that if i have lots of users who are trying to add websites , if every time a website is added i have to service uwsgi start/stop and service nginx restart .. the website will have problems when a user is trying to access it .
Is there any solution on how can i update the changes withoud restarting the services?
Any help or advice would be apreciated. Thank you!

By : Rus Mine


Answers

First, let's start with uWSGI.

If you're trying to launch all of your apps on one uWSGI server, you're doing something wrong. Each django app should require separate uWSGI server...

... and there is solution for that built into uWSGI: emperor and vassals. Just configure emperor as main uWSGI service and configure it in way that it can dynamically start and stop vassals without restarting itself. That way, if someone will change configuration of django app, only one vassal will be started/stopped or reloaded (something must happen, you can't avoid that).

Now let's configure nginx

For nginx is unfortunately hard to achieve. First of all, you don't have to restart nginx, you can gracefully reload it's config using service nginx reload. But if you're not fine with that, there is another solution.

For that solution to work, all of your django projects must have exact same nginx configuration (if you want to create some differences between them, check if it is achievable in uWSGI, with clever nginx config, you will able to use any uWSGI feature). If this requirement can be met, just do that:

  1. create config file for catching all of possible django websites (each of them must be at different domain), it can look like this:

    server {
        server_name   ~^(www\.)?(?


This video can help you solving your question :)
By: admin