因此,我有一个Dockerfile,在这里我想保留我的scrapyd服务器。但是,由于我使用scrapyd-deploy来部署Scrapy项目,所以我需要等待scrapyd服务器在部署鸡蛋之前运行。我不知道如何用Docker实现这一点,因为如果我使用scrapyd作为入口点,它会“窃取”终端,并且无法按顺序运行scrapyd-deploy。
现在,我有一些有用的东西,但这看起来真的,真的“无趣”,我不喜欢它。怎样才是正确的方法呢?
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有什么想法或建议吗?
发布于 2018-12-23 22:01:13
是的,我知道用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 scrapydhttps://stackoverflow.com/questions/53890489
复制相似问题