Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Nginx allows you to setup failover for your reverse proxies you can put one gunicorn instance as the primary and as long as that version is running it will never look at the failover. </p> <p>If you configure your site so that your new version is in the failover instance you just need to write your fab file to update the failure instance with the new version of the site and then when ready, turn off primary instance. Nginx will seamlessly failover to second instance and bam you are running on new version with no downtime.</p> <p>You can then update the primary version and then turn it back on and your primary is now live. At this point you can keep the failover instance running just in case, or turn it off.</p> <p>Some things to consider. You have to be careful with databases, if you are using sqllite make sure both gunicorn instances can accesss the sqllite file. </p> <p>If you have a normal database this is less of a problem, you just need to make sure you apply any database migrations that the new version needs before you switch to it. </p> <p>If they are backwards compatible changes then it isn't a big deal. If they aren't backwards compatible then be careful, you could break the old version of the site before you switch over to new version.</p> <p>To make things easier I would run the versions on different virtual environments.</p> <p>If you use supervisord to control gunicorn, then you can use the supervisorctl commands to reload/restart which ever instance you want to deploy without affecting the other one.</p> <p>Hope that helps</p> <p>Here is an example of and nginx config (not a full config file, removed the unimportant parts)</p> <p>This assumes the primary gunicorn instance is running on port 9005 and the other is running on port 9006</p> <pre><code>upstream service-backend { server localhost:9005; # primary server localhost:9006 backup; # only used when primary is down } server { listen 80; root /opt/htdocs; server_name localhost; access_log /var/logs/nginx/access.log; error_log /var/logs/nginx/error.log; location / { proxy_pass http://service-backend; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload