v2: ID verification by state, 15 photos/5 albums, 20 quick replies, logo, mobile polish
This commit is contained in:
@@ -1,16 +1,10 @@
|
||||
#!/usr/bin/env python3
|
||||
import io
|
||||
import os
|
||||
import tarfile
|
||||
import paramiko
|
||||
|
||||
HOST = "10.10.0.10"
|
||||
USER = "localadministrator"
|
||||
PASS = "Bbt9115xty9176!"
|
||||
GITEA_TOKEN = "5c323b8ea677d78b201341f6833d57156a607008"
|
||||
APP = "ira4bw4nhbvm87o7s3fgqu6v"
|
||||
PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
GIT_AUTH = f"https://{USER}:{GITEA_TOKEN}@gitea.onsethost.com/localadministrator/exposedgays.git"
|
||||
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
@@ -22,58 +16,38 @@ def run(cmd, t=300):
|
||||
_, o, e = c.exec_command(cmd, timeout=t)
|
||||
code = o.channel.recv_exit_status()
|
||||
out = (o.read() + e.read()).decode(errors="replace")
|
||||
print(out[-10000:])
|
||||
print(out[-5000:])
|
||||
print("exit", code, "\n")
|
||||
return code, out
|
||||
|
||||
|
||||
# Upload updated tarball
|
||||
buf = io.BytesIO()
|
||||
with tarfile.open(fileobj=buf, mode="w:gz") as tar:
|
||||
for root, dirs, files in os.walk(PROJECT_ROOT):
|
||||
dirs[:] = [d for d in dirs if d not in (".next", "node_modules", ".git")]
|
||||
for f in files:
|
||||
if f in (".env.local",):
|
||||
continue
|
||||
full = os.path.join(root, f)
|
||||
arc = os.path.relpath(full, PROJECT_ROOT)
|
||||
tar.add(full, arcname=arc)
|
||||
buf.seek(0)
|
||||
sftp = c.open_sftp()
|
||||
sftp.putfo(buf, "/tmp/exposedgays.tar.gz")
|
||||
sftp.close()
|
||||
|
||||
run("rm -rf /tmp/exposedgays && mkdir -p /tmp/exposedgays && tar -xzf /tmp/exposedgays.tar.gz -C /tmp/exposedgays")
|
||||
run(
|
||||
"cd /tmp/exposedgays && git add -A && "
|
||||
"git commit -m 'Fix Dockerfile: npm install fallback when no lockfile' || true && "
|
||||
f"git push origin main"
|
||||
)
|
||||
|
||||
# Get latest deployment log
|
||||
run(
|
||||
f"TOKEN=$(cat /home/localadministrator/.coolify-token | tail -1); "
|
||||
f"curl -sS 'http://127.0.0.1:8000/api/v1/applications/{APP}/deployments' "
|
||||
f'-H "Authorization: Bearer $TOKEN" | python3 -c "import sys,json;d=json.load(sys.stdin); '
|
||||
f'items=d if isinstance(d,list) else d.get(\\\"deployments\\\",d); '
|
||||
f'[print(x.get(\\\"deployment_uuid\\\"),x.get(\\\"status\\\"),x.get(\\\"failure_reason\\\")) for x in items[:3]]" 2>/dev/null'
|
||||
)
|
||||
|
||||
run(
|
||||
"TOKEN=$(cat /home/localadministrator/.coolify-token | tail -1); "
|
||||
f"curl -sS -X POST 'http://127.0.0.1:8000/api/v1/deploy?uuid={APP}&force_rebuild=true' "
|
||||
'-H "Authorization: Bearer $TOKEN"'
|
||||
)
|
||||
|
||||
for i in range(30):
|
||||
success = False
|
||||
for i in range(200):
|
||||
_, 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:
|
||||
print("DEPLOY DONE")
|
||||
break
|
||||
if "ApplicationDeploymentJob" in out and "FAIL" in out:
|
||||
print("DEPLOY FAIL - fetching logs")
|
||||
break
|
||||
if "ApplicationDeploymentJob" in out:
|
||||
if "DONE" in out:
|
||||
success = True
|
||||
print("=== DEPLOY SUCCESS ===")
|
||||
break
|
||||
if "FAIL" in out:
|
||||
print("=== DEPLOY FAILED ===")
|
||||
break
|
||||
|
||||
run("docker ps --format '{{.Names}} {{.Status}}' | grep -i ira4 || docker ps --format '{{.Names}} {{.Status}}' | grep -i exposed || true")
|
||||
run(
|
||||
"docker exec coolify-db psql -U coolify -d coolify -c "
|
||||
"\"SELECT id,status FROM application_deployment_queues WHERE application_id='31' ORDER BY id DESC LIMIT 1;\""
|
||||
)
|
||||
run(
|
||||
"docker exec coolify-db psql -U coolify -d coolify -c "
|
||||
"\"SELECT status,name FROM applications WHERE uuid='ira4bw4nhbvm87o7s3fgqu6v';\""
|
||||
)
|
||||
run("ssh -o StrictHostKeyChecking=no localadministrator@10.10.0.115 'docker ps --format \"{{.Names}} {{.Status}}\" | grep ira4' 2>&1")
|
||||
|
||||
c.close()
|
||||
c.close()
|
||||
print("SUCCESS" if success else "CHECK_LOGS")
|
||||
Reference in New Issue
Block a user