我正在尝试执行一项cron作业,该作业每分钟需要我的flask应用程序的终结点。构建并运行图像后,如果运行crontab -l
,但烧瓶未报告任何呼叫,我可以看到工作。知道为什么吗?任何帮助表示赞赏!这是设置
Dockerfile:
FROM python:3
WORKDIR /app
COPY . /app
RUN apt-get update && apt-get install -y cron curl
RUN pip install --trusted-host pypi.python.org -r requirements.txt
EXPOSE 13800
RUN chmod -v +x start.sh
CMD ["./start.sh"]
这是start.sh里面的内容:
#!/bin/sh
/usr/bin/crontab periodicGossipInvoker
# start cron
service cron start
# Flask
python main.py
这是periodicGossipInvoker的内部内容:
* * * * * sleep 10; /usr/bin/curl http://0.0.0.0:13800/dict
运行:
$ docker run --name="node1" --net=kv_subnet \
> --ip=10.10.0.2 -p 13802:13800 \
> -e ADDRESS="${addr1}" \
> -e VIEW=${initial_full_view} \
> -e REPL_FACTOR=2 \
> kv-store:4.0
Starting periodic command scheduler: cron.
* Serving Flask app "main" (lazy loading)
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: on
* Running on http://0.0.0.0:13800/ (Press CTRL+C to quit)
* Restarting with stat
* Debugger is active!
* Debugger PIN: 104-728-720
问题是,即使我在工作时看到了cron作业,flask应用也从未收到cron作业的任何呼叫
docker exec -ti 556 crontab -l
* * * * * sleep 10; /usr/bin/curl http://0.0.0.0:13800/dict