feat: develop添加一个测试任务

This commit is contained in:
caoqianming 2024-10-18 09:43:06 +08:00
parent f85db52ec7
commit abeb70d166
1 changed files with 16 additions and 10 deletions

View File

@ -10,14 +10,11 @@ def backup_database():
备份数据库
"""
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 = 'echo "{}" | sudo -S pg_dump "user={} password={} dbname={}" > {}/bak_{}.sql'.format(
SD_PWD,
DATABASES['default']['USER'],
DATABASES['default']['PASSWORD'],
DATABASES['default']['NAME'],
BACKUP_PATH + '/database',
name)
SD_PWD, DATABASES["default"]["USER"], DATABASES["default"]["PASSWORD"], DATABASES["default"]["NAME"], BACKUP_PATH + "/database", name
)
completed = subprocess.run(command, shell=True, capture_output=True, text=True)
if completed.returncode != 0:
return completed.stderr
@ -25,7 +22,7 @@ def backup_database():
@shared_task
def reload_server_git():
command = 'bash {}/git_server.sh'.format(SH_PATH)
command = "bash {}/git_server.sh".format(SH_PATH)
completed = subprocess.run(command, shell=True, capture_output=True, text=True)
if completed.returncode != 0:
return completed.stderr
@ -33,7 +30,7 @@ def reload_server_git():
@shared_task
def reload_web_git():
command = 'bash {}/git_web.sh'.format(SH_PATH)
command = "bash {}/git_web.sh".format(SH_PATH)
completed = subprocess.run(command, shell=True, capture_output=True, text=True)
if completed.returncode != 0:
return completed.stderr
@ -48,7 +45,16 @@ def reload_server_only():
@shared_task
def backup_media():
command = 'bash {}/backup_media.sh'.format(SH_PATH)
command = "bash {}/backup_media.sh".format(SH_PATH)
completed = subprocess.run(command, shell=True, capture_output=True, text=True)
if completed.returncode != 0:
return completed.stderr
@shared_task
def test_task():
import time
while True:
print("test")
time.sleep(10)