< H1 > briefly explain the train of thought < / H1 >
< H2 > the first step is to create a git remote repository on the server < / H2 >
cd /home/username
mkdir -p repositories/projectname.git
cd repositories/projectname.git
git init --bare .
< H2 > the second step is to write
post-receive
(
Git Hooks
) automatic deployment script on the server < / H2 >
touch /home/username/repositories/projectname.git/hooks/post-receive
chmod +x /home/username/repositories/projectname.git/hooks/post-receive
more complex logic may actually be required. Here is only an explanation
-sharp!/bin/bash
/usr/bin/git --work-tree=/var/www/projectname --git-dir=/home/username/repositories/projectname.git checkout -f
/home/username/.virtualenvs/virtualenvname/bin/python /home/username/.virtualenvs/virtualenvname/bin/uwsgi --reload /path/to/uwsgi.pid
remarks : user username
must have / var/www/projectname
directory read and write permissions
< H2 > step 3, add a remote warehouse locally < / H2 >
cd /path/to/projectdir
git remote add production username@myhostname:/home/username/repositories/projectname.git
-sharp
git push production master
-sharp post-receive
you can use Jenkins, if you want to use a mature solution, but you need to deploy Jenkins, on a server that takes up a little bit of memory. A simpler solution can use GitHub webhooks, and then write a flask application specifically used to update the service. There is only one interface to perform the task of shutting down the service, updating the code, running the test, and restarting the service. Call commands directly with os.system or subprocess.call.