Closed it985 closed 3 weeks ago
这部分应该可以适当优化,在启动容器时一步到位完成 后续会考虑简化docker部署的操作,感谢反馈
这部分应该可以适当优化,在启动容器时一步到位完成 后续会考虑简化docker部署的操作,感谢反馈
好的,期待ing....
之前做了个测试可以大概可以作为解决方案之一:
cron-lite
,直接将爬虫 run.py
作为子进程通过 cron 调用新建 py 如下:
import os
from cron_lite import cron_task, start_all
from threading import Thread
@cron_task("0 0/8 * * *")
def spider_task():
print("[cron]: fcircle spider start!")
os.system("python -u ./fcircle/run.py")
if __name__ == "__main__":
api_process = start_all(spawn = True)
os.system("python -u ./api/main.py")
FROM python:3.10.11-alpine3.18
MAINTAINER noionion
EXPOSE 8000
WORKDIR /home/fcircle_server
COPY . /home/fcircle_server
ENV TimeZone=Asia/Shanghai
ENV BASEPATH=/home/fcircle_server/
RUN pip3 install -r ./requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple \
&& ln -snf /usr/share/zoneinfo/$TimeZone /etc/localtime && echo $TimeZone > /etc/timezone
CMD ["python3", "-u", "./main.py"]
docker run -d \
--name fcircle \
-p 8000:8000 \
fcircle:xxx
以上仅供参考,对现在友圈的配置和逻辑不太熟悉了,不太好直接修改进行 pull 了。但依照大多数提供 docker 部署的开源程序,提供 docker 部署的单指令是较为常态化的解决方案。setting.py的内容也可以考虑移动到前端设置中。
docker部署 文中写道 1,clone repo 2,docker pull yyyzyyyz/fcircle:latest 3,python3 deploy.py 选择docker--->部署 可以直接优化成docker pull yyyzyyyz/fcircle:latest (可以直接一步到位) 原因,都用docker了,再让使用者去python3 deploy.py 选择部署方式是不是有点繁琐(ps:至少我个人来说)