From 1bac55cf54f048678d14ed174ce8303ad574fbed Mon Sep 17 00:00:00 2001 From: seahi Date: Thu, 17 Apr 2025 21:53:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=B0=E9=97=BB=E8=84=9A?= =?UTF-8?q?=E6=9C=AC=E7=9A=84=E6=97=A5=E5=BF=97=E6=A0=BC=E5=BC=8F=E4=B8=BA?= =?UTF-8?q?json?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 2 +- scripts/news_broadcast.sh | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9391f4a..a06183f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,4 +5,4 @@ RUN apk add --no-cache supervisor bash COPY supervisor /etc/supervisor COPY scripts /scripts -CMD ["/usr/bin/supervisord"] +CMD ["/usr/bin/supervisord","-c","/etc/supervisor/conf.d/supervisord.conf"] diff --git a/scripts/news_broadcast.sh b/scripts/news_broadcast.sh index 2bc3414..2bd12e9 100644 --- a/scripts/news_broadcast.sh +++ b/scripts/news_broadcast.sh @@ -3,8 +3,19 @@ echo "新闻播报服务启动中..." while true do - # 模拟每5秒输出一次新闻头条 - echo "[新闻播报] 当前时间: $(date '+%Y-%m-%d %H:%M:%S'),头条:今日科技新闻,新型AI技术发布!" + # 获取当前时间 + current_time=$(date '+%Y-%m-%d %H:%M:%S') + # 构建JSON格式的日志 + json_log=$(cat << EOF +{ + "service": "新闻播报", + "timestamp": "$current_time", + "headline": "今日科技新闻,新型AI技术发布!" +} +EOF +) + # 输出JSON格式的日志 + echo "$json_log" sleep 5 done