C
C
c4824212016-04-16 17:11:21
Nginx
c482421, 2016-04-16 17:11:21

How to deploy a python project from github to vps?

Suppose there is a project on github (for example, https://github.com/username/projectname , the repository is open), changes are made to it and pushes are made from several developers' computers.

I have a vps with python, flask, gunicorn, nginx, git and supervisor installed. Supervisor is configured to start gunicorn automatically when the server is restarted, nginx works to return statics, gunicorn - dynamics. How to make it so that:

1. The VPS server itself periodically (for example, once every 10 minutes) polls the github repository for changes in the master branch and automatically downloads this master branch, reboots the server (and how to do a hot deploy in this case)
2. It would be possible to manually update the contents of the project (i.e. source codes) on the VPS from the SSH console (if the repository is initialized in the working directory with the git init and git add commands .) It is desirable that the server does not stop working.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
DuD, 2016-04-16
@DuD

Look in the direction of hooks: https://git-scm.com/docs/githooks
Well, either by cron.

A
Alexey Yeletsky, 2016-04-17
@Tiendil

1. Don't do this, not every push to the master may require a release, in the end it can be done by mistake.
2. You can arrange the project in a standard Python package and install pip directly from the github. More or less like this:
3. In order not to climb every time on prod, you can write a deployment script that will stop / start all the necessary things, install packages, and so on. For example, using www.fabfile.org

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question