自动打包部署

This commit is contained in:
caoqianming 2022-02-28 22:06:31 +08:00
parent 8e9642ab63
commit a350e0085f
2 changed files with 9 additions and 4 deletions

View File

@ -12,15 +12,13 @@ def backup_database():
""" """
import datetime import datetime
name = datetime.datetime.now().strftime('%Y%m%d%H%M%S') name = datetime.datetime.now().strftime('%Y%m%d%H%M%S')
command = '''pg_dump "user=postgres password=zcDsj2021 dbname=hberp" > command = '''pg_dump "user=postgres password=zcDsj2021 dbname=hberp" > /home/lighthouse/backup/hberp_{}.sql'''.format(name)
/home/lighthouse/backup/hberp_{}.sql'''.format(name)
completed = subprocess.run(command, shell=True, capture_output=True, text=True) completed = subprocess.run(command, shell=True, capture_output=True, text=True)
return completed return completed
@shared_task @shared_task
def reload_server(): def reload_server():
os.chdir('/home/lighthouse/hberp') command = 'bash /home/lighthouse/hberp/hb_server/git.sh'
command = 'sudo git pull && sudo service supervisor reload'
completed = subprocess.run(command, shell=True, capture_output=True, text=True) completed = subprocess.run(command, shell=True, capture_output=True, text=True)
return completed return completed

7
hb_server/git.sh Normal file
View File

@ -0,0 +1,7 @@
#!/bin/bash
cd /home/lighthouse/hberp
sudo git pull
cd /home/lighthouse/hberp/hb_client
npm run build:prod
rsync -avu /home/lighthouse/hberp/hb_client/dist/ /home/lighthouse/hberp/hb_server/vuedist/
sudo service supervisor reload