-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmanage_server.sh
More file actions
executable file
·77 lines (67 loc) · 1.99 KB
/
manage_server.sh
File metadata and controls
executable file
·77 lines (67 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/bin/bash
# x-reader 服务管理脚本
PLIST_NAME="com.lobsterai.xreader"
PLIST_PATH="$HOME/Library/LaunchAgents/$PLIST_NAME.plist"
LOG_DIR="$HOME/Documents/LobsterAI/lzw/x-reader/logs"
case "$1" in
start)
echo "启动x-reader服务..."
launchctl start $PLIST_NAME
echo "服务已启动"
;;
stop)
echo "停止x-reader服务..."
launchctl stop $PLIST_NAME
echo "服务已停止"
;;
restart)
echo "重启x-reader服务..."
launchctl stop $PLIST_NAME
sleep 2
launchctl start $PLIST_NAME
echo "服务已重启"
;;
status)
echo "x-reader服务状态:"
launchctl list | grep $PLIST_NAME
echo ""
echo "服务端口占用:"
lsof -i :8081 2>/dev/null || echo "端口8081未被占用"
;;
logs)
echo "显示最近20行日志:"
echo "=== 标准输出 ==="
tail -20 "$LOG_DIR/server.log"
echo ""
echo "=== 错误输出 ==="
tail -20 "$LOG_DIR/server_error.log"
;;
logs-tail)
echo "实时监控日志 (按Ctrl+C退出):"
tail -f "$LOG_DIR/server.log" "$LOG_DIR/server_error.log"
;;
enable)
echo "设置开机自启动..."
launchctl load -w $PLIST_PATH
echo "已设置开机自启动"
;;
disable)
echo "取消开机自启动..."
launchctl unload -w $PLIST_PATH
echo "已取消开机自启动"
;;
*)
echo "x-reader 服务管理脚本"
echo "用法: $0 [命令]"
echo ""
echo "可用命令:"
echo " start 启动服务"
echo " stop 停止服务"
echo " restart 重启服务"
echo " status 查看状态"
echo " logs 查看最近日志"
echo " logs-tail 实时监控日志"
echo " enable 设置开机自启动"
echo " disable 取消开机自启动"
;;
esac