zioinfo-mail/scripts/setup/fix_deploy_server_url2.py
DESKTOP-TKLFCPR\ython 5561d0d050 feat(cicd): fix webhook server, git URLs, push Jenkinsfiles to all 5 Gitea repos
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-01 19:55:19 +09:00

42 lines
1.4 KiB
Python

"""deploy_server.py git URL 정확히 수정"""
import paramiko, sys
sys.stdout.reconfigure(encoding='utf-8', errors='replace')
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect('101.79.17.164', username='root', password='1q2w3e!Q', timeout=15)
def run(label, cmd, timeout=30):
print(f'\n[{label}]')
_, o, e = client.exec_command(cmd, timeout=timeout)
out = o.read().decode('utf-8', 'replace').strip()
if out: print(out[:800])
return out
# 서버에서 deploy_server.py 내용 읽어서 URL 패턴 전체 확인
run('전체 git 관련 라인', "grep -n 'git\|clone\|pull\|localhost\|9003\|3000' /opt/zioinfo/deploy_server.py")
# @localhost:3000 → @127.0.0.1:9003 으로 교체
run('URL 교체', r"""
sed -i 's/@localhost:3000\//@127.0.0.1:9003\//g' /opt/zioinfo/deploy_server.py
echo "완료"
grep -n 'localhost\|9003' /opt/zioinfo/deploy_server.py
""")
# 서비스 재시작
run('서비스 재시작', 'systemctl restart zioinfo-deploy && sleep 2 && systemctl is-active zioinfo-deploy')
# 실제 배포 트리거 테스트
run('guardia-itsm 배포 트리거', """
curl -sf -X POST http://localhost:9999 \
-H 'Content-Type: application/json' \
-H 'X-Gitea-Event: push' \
-d '{"repository":{"name":"guardia-itsm"},"ref":"refs/heads/main"}' \
2>/dev/null
""")
import time; time.sleep(8)
run('배포 결과 로그', 'tail -20 /var/log/zioinfo/deploy.log 2>/dev/null')
client.close()