更新服务器信息为新的 IP 地址,调整相关文档和代码中的默认配置,确保部署和连接的一致性。同时,优化订单管理界面,增强商品信息的格式化逻辑,提升用户体验。
This commit is contained in:
62
scripts/check_deployment.py
Normal file
62
scripts/check_deployment.py
Normal file
@@ -0,0 +1,62 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""检查部署状态"""
|
||||
|
||||
import paramiko
|
||||
import sys
|
||||
|
||||
SSH_CONFIG = {
|
||||
'hostname': '43.139.27.93',
|
||||
'port': 22022,
|
||||
'username': 'root',
|
||||
'password': 'Zhiqun1984'
|
||||
}
|
||||
|
||||
def run_command(ssh, cmd, description):
|
||||
"""执行SSH命令"""
|
||||
print(f"\n[CMD] {description}")
|
||||
print(f" > {cmd}")
|
||||
stdin, stdout, stderr = ssh.exec_command(cmd)
|
||||
output = stdout.read().decode('utf-8', errors='ignore')
|
||||
error = stderr.read().decode('utf-8', errors='ignore')
|
||||
|
||||
if output:
|
||||
print(output)
|
||||
if error and 'warning' not in error.lower():
|
||||
print(f"[ERROR] {error}")
|
||||
|
||||
return output
|
||||
|
||||
def main():
|
||||
print("="*60)
|
||||
print("Deployment Status Check")
|
||||
print("="*60)
|
||||
|
||||
try:
|
||||
# SSH连接
|
||||
ssh = paramiko.SSHClient()
|
||||
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
ssh.connect(**SSH_CONFIG)
|
||||
print("[OK] SSH connected")
|
||||
|
||||
# 1. 检查PM2状态
|
||||
run_command(ssh, 'pm2 status', '1. PM2 process status')
|
||||
|
||||
# 2. 检查最新日志
|
||||
run_command(ssh, 'pm2 logs soul --lines 20 --nostream', '2. Recent PM2 logs')
|
||||
|
||||
# 3. 检查端口监听
|
||||
run_command(ssh, 'netstat -tuln | grep 30006', '3. Port 30006 listening status')
|
||||
|
||||
# 4. 验证API是否正常
|
||||
run_command(ssh, 'curl -s http://localhost:30006/api/config | head -c 200', '4. API health check')
|
||||
|
||||
ssh.close()
|
||||
print("\n[OK] Check completed")
|
||||
|
||||
except Exception as e:
|
||||
print(f"[ERROR] {e}")
|
||||
sys.exit(1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user