"""CI/CD 배포 현황 확인""" import paramiko, sys, json, time 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): _, o, e = client.exec_command(cmd, timeout=timeout) out = o.read().decode('utf-8', errors='replace').strip() status = 'active' in out.lower() or 'running' in out.lower() return out, status checks = [ ('홈페이지 (zioinfo)', 'systemctl is-active zioinfo'), ('GUARDiA ITSM (guardia)', 'systemctl is-active guardia'), ('Manager (guardia-manager)', 'systemctl is-active guardia-manager 2>/dev/null || echo inactive'), ('Gitea', 'systemctl is-active gitea'), ('deploy-webhook', 'systemctl is-active zioinfo-deploy'), ] print('=== 서비스 상태 ===') for label, cmd in checks: out, ok = run(label, cmd) mark = 'OK' if ok else 'NG' print(f' [{mark}] {label}: {out}') # 최근 배포 로그 print('\n=== 최근 배포 로그 (10줄) ===') _, o, _ = client.exec_command('tail -10 /var/log/zioinfo/deploy.log 2>/dev/null', timeout=10) print(o.read().decode('utf-8', errors='replace').strip()) # 각 시스템 최신 git 커밋 print('\n=== 서버 코드 현황 ===') for label, path in [('홈페이지', '/opt/zioinfo/src'), ('ITSM', '/opt/guardia/app')]: _, o, _ = client.exec_command(f'git -C {path} log --oneline -2 2>/dev/null', timeout=10) print(f' {label}: {o.read().decode("utf-8", errors="replace").strip()[:80]}') client.close()