Skip to content

Commit

Permalink
feat: docker输出日志
Browse files Browse the repository at this point in the history
  • Loading branch information
14790897 committed Apr 6, 2024
1 parent 289323c commit a0a13e6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ RUN apt-get update && apt-get install -y \
xdg-utils \
--no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
#时区为中国
ENV TZ=Asia/Shanghai

# 安装 Node.js 依赖
RUN npm install
Expand All @@ -58,10 +60,13 @@ RUN npm install
COPY . .

# 创建一个新的 crontab 文件
RUN echo "0 3 * * * node /app/pteer.js" > /etc/cron.d/puppeteer-cron
RUN echo "0 3 * * * node /app/pteer.js >> /var/log/cron.log 2>&1" > /etc/cron.d/puppeteer-cron

# 给 crontab 文件适当的权限
RUN chmod 0644 /etc/cron.d/puppeteer-cron

# 将 cron 设置为在前台运行
CMD ["cron", "-f"]
# 将 cron 日志文件的权限设置为可写
RUN touch /var/log/cron.log && chmod 0666 /var/log/cron.log

# 将 cron 设置为在前台运行,并将日志输出到控制台
CMD cron -f && tail -f /var/log/cron.log
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
version: "3.8" # 使用 Docker Compose 文件版本 3.8,根据需要可以更改
services:
paperai:
autoread:
image: 14790897/auto-read:latest
container_name: auto-read
# environment: # 设置环境变量(这里设置后不需要在.env文件中设置)
Expand Down

0 comments on commit a0a13e6

Please sign in to comment.