Files
MoFin/deploy/bot/xmpp_zhiwei_bot.py
知微 80d59c9331 feat: 统一部署目录——所有运行时文件归入MoFin repo
- deploy/bot/ — XMPP bot核心(xmpp_agent_core + xmpp_zhiwei_bot)
- deploy/profile-scripts/ — cron脚本(price_monitor等)
- 运行时文件已替换为指向MoFin的符号链接
- 改代码只需改MoFin,系统自动生效
2026-07-17 23:12:35 +08:00

26 lines
725 B
Python

#!/usr/bin/env python3
"""Wrapper for xmpp_agent_core.py --agent zhiwei"""
import sys, os, signal
PID_FILE = "/tmp/xmpp_zhiwei_bot.pid"
if os.path.exists(PID_FILE):
with open(PID_FILE) as f:
try:
old_pid = int(f.read().strip())
os.kill(old_pid, 0)
print(f"xmpp_zhiwei_bot already running (PID {old_pid}), exiting.")
sys.exit(0)
except (ValueError, ProcessLookupError):
pass
with open(PID_FILE, "w") as f:
f.write(str(os.getpid()))
sys.argv = [sys.argv[0], '--agent', 'zhiwei']
try:
exec(open(os.path.join(os.path.dirname(__file__), 'xmpp_agent_core.py')).read())
finally:
if os.path.exists(PID_FILE):
os.remove(PID_FILE)