mirror of
https://github.com/Websoft9/websoft9.git
synced 2025-01-24 01:50:19 +08:00
部分修改删除
This commit is contained in:
parent
49646ef6ea
commit
e3b96a4e74
@ -5,12 +5,12 @@ from api.utils import shell_execute
|
|||||||
# 获取所有app的信息
|
# 获取所有app的信息
|
||||||
def get_my_app():
|
def get_my_app():
|
||||||
|
|
||||||
my_cmd = my_app()
|
my_cmd = "sudo docker compose ls"
|
||||||
|
|
||||||
output = shell_execute.execute_command_output_all(my_cmd)
|
output = shell_execute.execute_command_output_all(my_cmd)
|
||||||
if int(output["code"]) == 0:
|
if int(output["code"]) == 0:
|
||||||
output_list = output["result"].split()
|
output_list = output["result"].split()
|
||||||
print(output_list)
|
print(output_list)
|
||||||
|
ret = {}
|
||||||
list = []
|
list = []
|
||||||
num = int(len(output_list)/3)
|
num = int(len(output_list)/3)
|
||||||
for i in range(1,num):
|
for i in range(1,num):
|
||||||
@ -19,45 +19,11 @@ def get_my_app():
|
|||||||
app['status_code'] = output_list[3*i+2].split("(")[0]
|
app['status_code'] = output_list[3*i+2].split("(")[0]
|
||||||
app['status'] = output_list[3*i+3]
|
app['status'] = output_list[3*i+3]
|
||||||
list.append(app)
|
list.append(app)
|
||||||
return list
|
ret["code"] = 0
|
||||||
|
ret["message"] = "app查询成功"
|
||||||
return -1
|
ret["data"] = list
|
||||||
|
else:
|
||||||
|
ret["code"] = -1
|
||||||
# 生成创建 App 的命令
|
ret["message"] = "app查询失败"
|
||||||
def my_app():
|
ret["data"] = None
|
||||||
|
return ret
|
||||||
my_app_cmd = ''
|
|
||||||
my_app_cmd = "sudo docker compose ls"
|
|
||||||
|
|
||||||
return my_app_cmd
|
|
||||||
|
|
||||||
|
|
||||||
# 生成创建 App 的命令
|
|
||||||
def create_app(app_name):
|
|
||||||
print(app_name)
|
|
||||||
|
|
||||||
create_cmd = ''
|
|
||||||
create_cmd = "sudo su && cd /data/apps/" + app_name + " && docker compose up -d"
|
|
||||||
|
|
||||||
return create_cmd
|
|
||||||
|
|
||||||
|
|
||||||
# 生成启动 App 的命令
|
|
||||||
def start_app(app_name):
|
|
||||||
print(app_name)
|
|
||||||
|
|
||||||
start_cmd = ''
|
|
||||||
start_cmd = "sudo su && docker compose start" + app_name
|
|
||||||
|
|
||||||
return start_cmd
|
|
||||||
|
|
||||||
|
|
||||||
# 生成停止 App 的命令
|
|
||||||
def stop_app(app_name):
|
|
||||||
print(app_name)
|
|
||||||
|
|
||||||
stop_cmd = ''
|
|
||||||
stop_cmd = "sudo su && docker compose stop" + app_name
|
|
||||||
|
|
||||||
return stop_cmd
|
|
||||||
|
@ -33,10 +33,10 @@ def create_app_directory(app_name):
|
|||||||
if isexsits:
|
if isexsits:
|
||||||
return
|
return
|
||||||
#2. git clone https://github.com/Websoft9/docker-library.git项目,将apps复制到/data目录,如果data目录没有,创建
|
#2. git clone https://github.com/Websoft9/docker-library.git项目,将apps复制到/data目录,如果data目录没有,创建
|
||||||
shell_execute.execute_command_output_all("git clone https://github.com/Websoft9/docker-library.git")
|
shell_execute.execute_command_output_all("git clone https://github.com/Websoft9/docker-library.git /data")
|
||||||
if not os.path.exists("/data"):
|
if not os.path.exists("/data"):
|
||||||
os.makedirs("/data")
|
os.makedirs("/data")
|
||||||
copy_dir("docker-library","/data")
|
copy_dir("/data/docker-library","/data")
|
||||||
|
|
||||||
def check_app_compose(app_name):
|
def check_app_compose(app_name):
|
||||||
path = "/data/apps/" + app_name + ".env"
|
path = "/data/apps/" + app_name + ".env"
|
||||||
|
Loading…
Reference in New Issue
Block a user