FIX autodl自动创建修复
This commit is contained in:
parent
43479f043d
commit
61106608e0
|
|
@ -11,6 +11,7 @@ req_instance_page_size = 1500
|
||||||
chk_instance_page_size = 1500
|
chk_instance_page_size = 1500
|
||||||
instances = {}
|
instances = {}
|
||||||
LIM = 30 # 等待状态时间LIM*5s
|
LIM = 30 # 等待状态时间LIM*5s
|
||||||
|
START_LIM = 20 #Heygem脚本启动等待超时时间-10
|
||||||
|
|
||||||
def ssh_try(host,port,pwd):
|
def ssh_try(host,port,pwd):
|
||||||
# 建立连接
|
# 建立连接
|
||||||
|
|
@ -21,10 +22,22 @@ def ssh_try(host,port,pwd):
|
||||||
ssh = paramiko.SSHClient()
|
ssh = paramiko.SSHClient()
|
||||||
ssh._transport = trans
|
ssh._transport = trans
|
||||||
|
|
||||||
# 剩下的就和上面一样了
|
|
||||||
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||||
ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command("/bin/bash -lc \"source /root/.bashrc && nohup python /root/AutoDL_pure_heygem.py > log.txt 2>&1 &\"")
|
ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command("bash -ic \"source /root/.bashrc && sleep 10 && ps -ef|grep heygem|grep -v grep && lsof -i:6006|wc -l\"", get_pty=True)
|
||||||
|
out = ssh_stdout.read().decode()
|
||||||
|
start_lim = START_LIM
|
||||||
|
if len(out.split("\n")[-2]) > 2:
|
||||||
|
trans.close()
|
||||||
|
raise RuntimeError(out.split("\n")[-2])
|
||||||
|
while int(out.split("\n")[-2]) <= 1 and start_lim > 0:
|
||||||
|
ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command("bash -ic \"sleep 2 && lsof -i:6006|wc -l\"")
|
||||||
|
out = ssh_stdout.read().decode()
|
||||||
|
loguru.logger.info("waiting for HeyGem server ready...")
|
||||||
|
start_lim -= 1
|
||||||
|
if start_lim <= 0:
|
||||||
|
loguru.logger.error("HeyGem Server Start Timeout, Please check!")
|
||||||
|
else:
|
||||||
|
loguru.logger.success("HeyGem Server Start Success")
|
||||||
# 关闭连接
|
# 关闭连接
|
||||||
trans.close()
|
trans.close()
|
||||||
|
|
||||||
|
|
@ -239,7 +252,7 @@ if __name__=="__main__":
|
||||||
machines = get_autodl_machines()
|
machines = get_autodl_machines()
|
||||||
for m in machines:
|
for m in machines:
|
||||||
instance_uuid, domain = payg(m["region_name"], m["machine_id"])
|
instance_uuid, domain = payg(m["region_name"], m["machine_id"])
|
||||||
print(instance_uuid, "https://"+domain)
|
loguru.logger.success("instance_id:%s server_domain: https://%s" % (instance_uuid, domain))
|
||||||
# if instance_uuid:
|
# if instance_uuid:
|
||||||
# instance_operate(instance_uuid, "power_off")
|
# instance_operate(instance_uuid, "power_off")
|
||||||
# instance_operate(instance_uuid, "release")
|
# instance_operate(instance_uuid, "release")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue