Hacker News new | ask | show | jobs
by Pephers 3898 days ago
For gunicorn running Flask I use something along the lines of for zero-downtime deploy which really works well as long as your app runs on a single server:

    rsync -avz ./ user@remote:/home/user/web-app
    ssh user@remote 'cd /home/user/web-app; \
    venv/bin/pip install -r requirements.txt; \
    venv/bin/alembic upgrade head; \
    supervisorctl pid web-app | xargs kill -HUP'
The full deployment script has a few extra options which I've omitted for clarity, but this is basically it.
1 comments

I don't really think you should promote these.

The real way to perform clean update is using a load balancer, offloading instances for upgrade one at a time.

Also please people stop deploying using github. Package management & versioning IS a thing.

> rsync -avz ./ user@remote:/home/user/web-app

This is not an atomic update, meaning that you could end up loading modules from the new version from code of the older version. Use a new directory to upload the new files.

> venv/bin/pip install -r requirements.txt

You do not delete the old requirements, this is incrementally bloating the virtualenv. Just create a new one, virtualenv are designed to be created/removed quickly.

> venv/bin/alembic upgrade head

Huu, that's nice if you only have 1 instance to upgrade at a time. Otherwise it will just blow up.