Compare commits

...
2 Commits
Author SHA1 Message Date
hz4th_coder 3107d56764 chore: 同步版本号至 v1.8.0(修正 tag 序列) 2026-08-19 11:57:08 +08:00
hz4th_coder 79a1ca36c5 feat: 添加 keepalive 保活脚本 + cron 定时检查
- 每5分钟检查服务是否运行
- 自动杀掉占用端口的非 node 进程(如 Python http.server)
- 自动重启 node 服务
2026-07-24 17:34:02 +08:00
3 changed files with 48 additions and 3 deletions
+1 -1
View File
@@ -3,7 +3,7 @@
一个简洁强大的数据可视化工具,支持 **Web UI****API** 两种方式生成精美的对比图表和表格图片。
![License](https://img.shields.io/badge/license-MIT-blue.svg)
![Version](https://img.shields.io/badge/version-1.2.0-green.svg)
![Version](https://img.shields.io/badge/version-1.8.0-green.svg)
## ✨ 功能特性
Executable
+45
View File
@@ -0,0 +1,45 @@
#!/bash
# data-chart-tool 保活脚本
# 检查服务是否运行,如果没有则启动
PORT=16016
APP_DIR="/home/openclaw/.openclaw/workspace-hz4th_coder/works/data-chart-tool"
LOG_FILE="$APP_DIR/logs/server.log"
# 检查端口是否被占用
if ss -tlnp | grep -q ":$PORT "; then
# 检查是不是 node 进程
PID=$(ss -tlnp | grep ":$PORT " | grep -oP 'pid=\K[0-9]+' | head -1)
if [ -n "$PID" ]; then
CMD=$(ps -p "$PID" -o comm= 2>/dev/null)
if [ "$CMD" = "node" ] || [ "$CMD" = "MainThread" ]; then
# node 服务在运行,检查是否正常响应
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:$PORT/api/health 2>/dev/null)
if [ "$HTTP_CODE" = "200" ]; then
echo "[$(date)] Service OK (PID=$PID, HTTP=$HTTP_CODE)"
exit 0
fi
fi
# 端口被非 node 进程占用(如 Python http.server),杀掉它
echo "[$(date)] Port $PORT occupied by $CMD (PID=$PID), killing..."
kill -9 "$PID" 2>/dev/null
sleep 1
fi
fi
# 启动 node 服务
echo "[$(date)] Starting data-chart-tool..."
cd "$APP_DIR"
nohup node server.js >> "$LOG_FILE" 2>&1 &
echo "[$(date)] Started with PID $!"
# 等待启动
sleep 2
# 验证
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:$PORT/api/health 2>/dev/null)
if [ "$HTTP_CODE" = "200" ]; then
echo "[$(date)] Service started successfully (HTTP=$HTTP_CODE)"
else
echo "[$(date)] WARNING: Service may not have started correctly (HTTP=$HTTP_CODE)"
fi
+2 -2
View File
@@ -882,7 +882,7 @@ app.get('/api/health', (req, res) => {
res.json({
status: 'ok',
service: 'data-chart-tool',
version: '1.2.0',
version: '1.8.0',
endpoints: {
'POST /api/chart': '生成图表图片(JSON body',
'GET /api/chart': '生成图表图片(URL 参数)',
@@ -897,7 +897,7 @@ app.get('/api/health', (req, res) => {
app.get('/api/docs', (req, res) => {
res.json({
name: '数据可视化图表生成器 API',
version: '1.2.0',
version: '1.8.0',
endpoints: [
{
method: 'POST',