创建sh文件夹
This commit is contained in:
parent
49666dcd49
commit
4388459247
|
@ -4,6 +4,7 @@
|
|||
venv/
|
||||
__pycache__/
|
||||
*.pyc
|
||||
sh/*
|
||||
media/*
|
||||
static/*
|
||||
vuedist/*
|
||||
|
|
|
@ -4,6 +4,7 @@ from rest_framework.response import Response
|
|||
from celery import shared_task
|
||||
import os
|
||||
import subprocess
|
||||
from server.settings_pro import DATABASES, BACKUP_DATABASE_PATH
|
||||
|
||||
@shared_task
|
||||
def backup_database():
|
||||
|
@ -12,13 +13,18 @@ def backup_database():
|
|||
"""
|
||||
import datetime
|
||||
name = datetime.datetime.now().strftime('%Y%m%d%H%M%S')
|
||||
command = '''pg_dump "user=postgres password=zcDsj2021 dbname=hberp" > /home/lighthouse/backup/database/hberp_{}.sql'''.format(name)
|
||||
command = 'pg_dump "user={} password={} dbname={}" > {}/hberp_{}.sql'.format(
|
||||
DATABASES['default']['USER'],
|
||||
DATABASES['default']['PASSWORD'],
|
||||
DATABASES['default']['NAME'],
|
||||
BACKUP_DATABASE_PATH,
|
||||
name)
|
||||
completed = subprocess.run(command, shell=True, capture_output=True, text=True)
|
||||
return completed
|
||||
|
||||
@shared_task
|
||||
def reload_server():
|
||||
command = 'bash /home/lighthouse/hberp/hb_server/git.sh'
|
||||
command = 'bash /home/lighthouse/hberp/hb_server/sh/git.sh'
|
||||
completed = subprocess.run(command, shell=True, capture_output=True, text=True)
|
||||
return completed
|
||||
|
||||
|
@ -30,7 +36,7 @@ def reload_server_only():
|
|||
|
||||
@shared_task
|
||||
def backup_media():
|
||||
command = 'rsync -avu /home/lighthouse/hberp/hb_server/media/ /home/lighthouse/backup/media/'
|
||||
command = 'bash /home/lighthouse/hberp/hb_server/sh/backup_media.sh'
|
||||
completed = subprocess.run(command, shell=True, capture_output=True, text=True)
|
||||
return completed
|
||||
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
#!/bin/bash
|
||||
cd /home/lighthouse/hberp/hb_server
|
||||
source venv/bin/activate
|
||||
exec celery -A server beat -l info
|
|
@ -1,4 +0,0 @@
|
|||
#!/bin/bash
|
||||
cd /home/lighthouse/hberp/hb_server
|
||||
source venv/bin/activate
|
||||
exec celery -A server worker -l info
|
|
@ -1,7 +0,0 @@
|
|||
#!/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
|
|
@ -1,4 +0,0 @@
|
|||
#!/bin/bash
|
||||
cd /home/lighthouse/hberp/hb_server
|
||||
source venv/bin/activate
|
||||
exec gunicorn -w 5 -b 0.0.0.0:2223 server.wsgi
|
Loading…
Reference in New Issue