运行 服务器启动后的命令 - Docker, scrapyd, scrapyd-deploy
Running command after server started - Docker, scrapyd, scrapyd-deploy
所以,我有一个 Dockerfile
,我想在其中保留我的 scrapyd
服务器。但是,由于我使用 scrapyd-deploy
来部署我的 Scrapy
项目,我需要等待 scrapyd
服务器到 运行 才能部署鸡蛋。我不确定如何使用 Docker
完成此操作,因为如果我使用 scrapyd
作为入口点,它 "steals" 终端并且我无法 运行 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
有什么想法或建议吗?
是的,我知道使用 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
所以,我有一个 Dockerfile
,我想在其中保留我的 scrapyd
服务器。但是,由于我使用 scrapyd-deploy
来部署我的 Scrapy
项目,我需要等待 scrapyd
服务器到 运行 才能部署鸡蛋。我不确定如何使用 Docker
完成此操作,因为如果我使用 scrapyd
作为入口点,它 "steals" 终端并且我无法 运行 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
有什么想法或建议吗?
是的,我知道使用 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