diff --git a/app.py b/app.py index 62cdead..67617ad 100644 --- a/app.py +++ b/app.py @@ -230,7 +230,7 @@ def register_routes(app, db): def statistics(): """统计信息""" stats = db.get_statistics() - recent = db.get_recent_messages(10) + recent = db.get_recent_messages(20) from_numbers = db.get_from_numbers() return render_template('statistics.html', diff --git a/nohup.out b/nohup.out new file mode 100644 index 0000000..b96305d --- /dev/null +++ b/nohup.out @@ -0,0 +1,15 @@ +[2026-02-06 23:52:11,314] INFO in app: 启动短信接收服务 (环境: development) +[2026-02-06 23:52:11,314] INFO in app: 启动短信接收服务 (环境: development) +[2026-02-06 23:52:11,314] INFO in app: 数据库: /root/.openclaw/workspace/sms-receiver/sms_receiver.db +[2026-02-06 23:52:11,314] INFO in app: 数据库: /root/.openclaw/workspace/sms-receiver/sms_receiver.db +[2026-02-06 23:52:11,314] INFO in app: 监听端口: 9518 +[2026-02-06 23:52:11,314] INFO in app: 监听端口: 9518 +[2026-02-06 23:52:11,315] INFO in app: 登录已启用: True +[2026-02-06 23:52:11,315] INFO in app: 登录已启用: True + * Serving Flask app 'app' + * Debug mode: off +[31m[1mWARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.[0m + * Running on all addresses (0.0.0.0) + * Running on http://127.0.0.1:9518 + * Running on http://199.188.198.12:9518 +[33mPress CTRL+C to quit[0m diff --git a/sms_receiver.service b/sms_receiver.service new file mode 100644 index 0000000..ed51304 --- /dev/null +++ b/sms_receiver.service @@ -0,0 +1,17 @@ +[Unit] +Description=SMS Receiver Web Service +After=network.target + +[Service] +Type=forking +User=root +WorkingDirectory=/root/.openclaw/workspace/sms-receiver +ExecStart=/root/.openclaw/workspace/sms-receiver/sms_receiverctl.sh start +ExecStop=/root/.openclaw/workspace/sms-receiver/sms_receiverctl.sh stop +ExecReload=/root/.openclaw/workspace/sms-receiver/sms_receiverctl.sh restart +PIDFile=/root/.openclaw/workspace/sms-receiver/sms_receiver.pid +Restart=always +RestartSec=5 + +[Install] +WantedBy=multi-user.target diff --git a/sms_receiverctl.sh b/sms_receiverctl.sh new file mode 100755 index 0000000..02a98bb --- /dev/null +++ b/sms_receiverctl.sh @@ -0,0 +1,90 @@ +#!/bin/bash +# 短信转发接收端 - 启动/停止/重启/状态脚本 + +APP_DIR="/root/.openclaw/workspace/sms-receiver" +APP_FILE="$APP_DIR/app.py" +PIDFILE="$APP_DIR/sms_receiver.pid" +LOGFILE="$APP_DIR/sms_receiver.log" + +case "$1" in + start) + if [ -f "$PIDFILE" ]; then + PID=$(cat "$PIDFILE") + if ps -p "$PID" > /dev/null 2>&1; then + echo "服务已在运行 (PID: $PID)" + exit 1 + else + rm -f "$PIDFILE" + fi + fi + + echo "启动短信转发接收端..." + cd "$APP_DIR" + nohup python3 app.py > "$LOGFILE" 2>&1 & + echo $! > "$PIDFILE" + echo "服务已启动 (PID: $(cat $PIDFILE))" + echo "日志文件: $LOGFILE" + echo "监听地址: http://0.0.0.0:9518" + ;; + + stop) + if [ ! -f "$PIDFILE" ]; then + echo "服务未运行" + exit 1 + fi + + PID=$(cat "$PIDFILE") + echo "停止服务 (PID: $PID)..." + kill "$PID" 2>/dev/null + sleep 1 + + if ps -p "$PID" > /dev/null 2>&1; then + echo "强制停止..." + kill -9 "$PID" 2>/dev/null + fi + + rm -f "$PIDFILE" + echo "服务已停止" + ;; + + restart) + $0 stop + sleep 2 + $0 start + ;; + + status) + if [ -f "$PIDFILE" ]; then + PID=$(cat "$PIDFILE") + if ps -p "$PID" > /dev/null 2>&1; then + echo "服务正在运行 (PID: $PID)" + echo "启动时间: $(ps -p $PID -o lstart=)" + echo "内存使用: $(ps -p $PID -o rss= | awk '{print int($1/1024)"MB"}')" + exit 0 + else + echo "PID 文件存在但进程未运行,清理..." + rm -f "$PIDFILE" + exit 1 + fi + else + echo "服务未运行" + exit 1 + fi + ;; + + log) + tail -f "$LOGFILE" + ;; + + *) + echo "用法: $0 {start|stop|restart|status|log}" + echo "" + echo "命令说明:" + echo " start - 启动服务" + echo " stop - 停止服务" + echo " restart - 重启服务" + echo " status - 查看状态" + echo " log - 查看实时日志" + exit 1 + ;; +esac diff --git a/templates/index.html b/templates/index.html index 567039c..bf30fb2 100644 --- a/templates/index.html +++ b/templates/index.html @@ -138,26 +138,54 @@ border-collapse: collapse; } - .messages-table th, - .messages-table td { - padding: 12px 15px; - text-align: left; + .messages-list { + background: white; + border-radius: 10px; + overflow: hidden; + box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); + } + + .list-view { + list-style: none; + } + + .list-view li { + padding: 15px; border-bottom: 1px solid #eee; + transition: background 0.3s; } - .messages-table th { - background: #f5f5f5; - font-weight: 600; - color: #333; - } - - .messages-table tr:hover { + .list-view li:hover { background: #f9f9f9; } + .list-view li:last-child { + border-bottom: none; + } + + .msg-header { + display: flex; + justify-content: space-between; + align-items: center; + margin-bottom: 8px; + } + .from-number { font-weight: bold; color: #667eea; + font-size: 15px; + } + + .msg-time { + font-size: 12px; + color: #999; + } + + .msg-content { + color: #333; + font-size: 14px; + line-height: 1.6; + word-break: break-all; } .sign-verified { @@ -351,40 +379,19 @@ -