68 lines
2.3 KiB
Python
68 lines
2.3 KiB
Python
#!/usr/bin/env python3
|
|
import paramiko
|
|
|
|
HOST = "10.10.0.10"
|
|
USER = "localadministrator"
|
|
PASS = "Bbt9115xty9176!"
|
|
APP = "ira4bw4nhbvm87o7s3fgqu6v"
|
|
|
|
c = paramiko.SSHClient()
|
|
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
c.connect(HOST, username=USER, password=PASS, timeout=20, allow_agent=False, look_for_keys=False)
|
|
|
|
|
|
def run(cmd, t=120):
|
|
print("$", cmd[:150])
|
|
_, o, e = c.exec_command(cmd, timeout=t)
|
|
code = o.channel.recv_exit_status()
|
|
out = (o.read() + e.read()).decode(errors="replace")
|
|
print(out[-20000:])
|
|
print("exit", code, "\n")
|
|
return code, out
|
|
|
|
|
|
run(
|
|
"docker exec coolify-db psql -U coolify -d coolify -c "
|
|
"\"SELECT id,status,left(logs,3000),deployment_url,server_name,commit "
|
|
"FROM application_deployment_queues WHERE application_id='31' "
|
|
"ORDER BY id DESC LIMIT 3;\""
|
|
)
|
|
|
|
run(
|
|
"docker exec coolify-db psql -U coolify -d coolify -c "
|
|
"\"SELECT column_name,data_type FROM information_schema.columns "
|
|
"WHERE table_name='applications' AND column_name LIKE '%dest%' OR table_name='applications' AND column_name LIKE '%server%';\""
|
|
)
|
|
|
|
run(
|
|
"docker exec coolify-db psql -U coolify -d coolify -c "
|
|
"\"SELECT * FROM applications WHERE uuid='ira4bw4nhbvm87o7s3fgqu6v'\\gx\" 2>/dev/null | head -80"
|
|
)
|
|
|
|
# Try update to localhost server
|
|
run(
|
|
"docker exec coolify-db psql -U coolify -d coolify -c "
|
|
"\"UPDATE applications SET destination_id=0, server_id=0 WHERE uuid='ira4bw4nhbvm87o7s3fgqu6v'; "
|
|
"SELECT destination_id,server_id,name FROM applications WHERE uuid='ira4bw4nhbvm87o7s3fgqu6v';\""
|
|
)
|
|
|
|
run(
|
|
"TOKEN=$(cat /home/localadministrator/.coolify-token | tail -1); "
|
|
"curl -sS -X POST 'http://127.0.0.1:8000/api/v1/deploy?uuid=ira4bw4nhbvm87o7s3fgqu6v&force_rebuild=true' "
|
|
'-H "Authorization: Bearer $TOKEN"'
|
|
)
|
|
|
|
for i in range(60):
|
|
_, out = run("docker exec coolify php artisan queue:work --queue=high,default --once --timeout=900 2>&1", t=920)
|
|
if "ApplicationDeploymentJob" in out and ("DONE" in out or "FAIL" in out):
|
|
break
|
|
|
|
run(
|
|
"docker exec coolify-db psql -U coolify -d coolify -c "
|
|
"\"SELECT id,status,left(logs,5000),deployment_url FROM application_deployment_queues "
|
|
"WHERE application_id='31' ORDER BY id DESC LIMIT 1;\""
|
|
)
|
|
|
|
run("docker ps --format '{{.Names}} {{.Status}}' | grep ira4 || true")
|
|
|
|
c.close() |