因此,我有一个Dockerfile
,我想保留我的scrapyd
服务器。但是,由于我使用scrapyd-deploy
来部署我的Scrapy
项目,因此我需要等待scrapyd
服务器运行之后再部署鸡蛋。我不确定如何使用Docker
完成此操作,因为如果我使用scrapyd
作为入口点,它将“窃取”终端,并且我无法依次运行scrapyd-deploy
。
就目前而言,我有一些可行的方法,但这对我来说看起来真的很“ hacky”,我不喜欢它。正确的方法是什么?
FROM python:3.6
SHELL [ "/bin/bash", "-c" ]
# here comes a lot of configuration, copying files, installing stuff, etc ...
# important part that I think is hacky comes at the end:
# the command below redirect scrapyd streams to /dev/null, send it to the background, deploy the eggs, than run a dummy command to keep the container alive
CMD scrapyd >& /dev/null & cd ali && scrapyd-deploy && tail -f /dev/null
有什么想法或建议吗?
答案 0 :(得分:0)
是的,我知道使用Linux管理流程应该没有那么复杂。 #loveLinux #linuxRocks
因此,我找到了一种方法,可以将scrapyd
服务器进程放到后台,用scrapyd-deploy
进行部署,然后再次将服务器放回到前台以避免Docker
终止我的容器。那是CMD
行,解决了所有问题(带有注释):
# Set bash monitor mode on; run server on the background, deploy eggs, get server to the foreground again.
CMD set -m; scrapyd & cd ali && scrapyd-deploy && fg scrapyd