mirror of
https://github.com/aaPanel/aaPanel.git
synced 2026-12-04 03:23:29 +01:00
55 lines
1.8 KiB
Python
55 lines
1.8 KiB
Python
#!/www/server/panel/pyenv/bin/python
|
|
# coding: utf-8
|
|
# -------------------------------------------------------------------
|
|
# aaPanel
|
|
# -------------------------------------------------------------------
|
|
# docker compose - 从 git 部署:后台任务 worker(按项目串行消费排队记录)
|
|
# -------------------------------------------------------------------
|
|
import sys
|
|
|
|
if "/www/server/panel" not in sys.path:
|
|
sys.path.insert(0, "/www/server/panel")
|
|
if "/www/server/panel/class" not in sys.path:
|
|
sys.path.insert(0, "/www/server/panel/class")
|
|
if "/www/server/panel/class_v2" not in sys.path:
|
|
sys.path.insert(0, "/www/server/panel/class_v2")
|
|
|
|
import public
|
|
|
|
|
|
def _parse_args(argv):
|
|
values = {}
|
|
for index, arg in enumerate(argv):
|
|
if arg.startswith("--") and "=" in arg:
|
|
key, value = arg.split("=", 1)
|
|
values[key[2:]] = value
|
|
elif arg.startswith("--") and index + 1 < len(argv):
|
|
values[arg[2:]] = argv[index + 1]
|
|
return values
|
|
|
|
|
|
def main():
|
|
args = _parse_args(sys.argv)
|
|
project_id = args.get("project-id", "")
|
|
deploy_id = args.get("deploy-id", "")
|
|
if not project_id:
|
|
return
|
|
from mod.project.docker.compose_git.deploy_manage import ComposeGitDeploy
|
|
worker = ComposeGitDeploy()
|
|
project_id = int(project_id)
|
|
if deploy_id:
|
|
# 指定记录时只执行该条;执行完继续消费同项目剩余排队任务
|
|
try:
|
|
worker.execute_deploy(project_id, int(deploy_id))
|
|
except Exception:
|
|
public.print_log(
|
|
"compose git deploy failed: {}".format(public.get_error_info()))
|
|
worker.execute_pending(project_id)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
try:
|
|
main()
|
|
except Exception:
|
|
public.print_log(public.get_error_info())
|