2015-06-06 43 views
2

为了开始启动硒服务器,cron作业破坏其它前台服务器在泊坞窗

我必须把entry_point.sh/opt/bin

,但如果我取消cron命令CMD cron && tail -f /var/log/cron.log

服务器韩元不再运行了。

我无法弄清楚,为什么它会被打破

这是我的cron文件

SHELL=/usr/bin/zsh 
* * * * * echo $PATH >> /root//reboot_record.txt >> /tmp/cron_debug_log.log 2>&1 
* * * * * cd /home/poc/lazy-bird/j && ruby j.rb >> /tmp/cron_debug_log.log 2>&1 
* * * * * echo $PATH >> /root//reboot_record.txt >> /tmp/cron_debug_log.log 2>&1 
* * * * * cd /home/poc/lazy-bird/p && ruby p.rb >> /tmp/cron_debug_log.log 2>&1 

这是我的搬运工文件

#==================================== 
# Scripts to run cron job 
#==================================== 
# Add crontab file in the cron directory 
ADD cron_lazy_bird /etc/crontab 
# Create the log file to be able to run tail 
RUN touch /var/log/cron.log 
# Use the crontab file 
RUN crontab /etc/crontab 
# Run the command on container startup 
#CMD cron && tail -f /var/log/cron.log 
#==================================== 
# Scripts to run Selenium Standalone 
#==================================== 
COPY entry_point.sh /opt/bin/entry_point.sh 
RUN chmod +x /opt/bin/entry_point.sh 
USER seluser 
EXPOSE 4444 
USER root 
CMD ["/bin/bash", "/opt/bin/entry_point.sh"] 

UPDATE entry_point.sh

cron && tail -f /var/log/cron.log 

export GEOMETRY="$SCREEN_WIDTH""x""$SCREEN_HEIGHT""x""$SCREEN_DEPTH" 

xvfb-run --server-args="$DISPLAY -screen 0 $GEOMETRY -ac +extension RANDR" \ 
    java -jar /opt/selenium/selenium-server-standalone.jar \ 
    -role node \ 
    -hub http://$HUB_1_PORT_4444_TCP_ADDR:$HUB_1_PORT_4444_TCP_PORT/grid/register \ 
    -browser browserName=firefox 

回答

0

您的入口点脚本需要从ENTRYPOINTCMD指令中调用,否则在启动容器时不会运行。

在启动应用程序之前,您需要删除CMD并从入口点脚本启动cron。您可能需要使用诸如runit或supervisord之类的进程管理器来处理此问题(请参阅https://docs.docker.com/articles/using_supervisord/)。

+0

谢谢,但我试过你的解决方案,它可能无法正常工作,这个过程将停留在'cron'而不是运行'xvfb-run'服务器。 – user3675188

+0

因此,正如我所建议的那样,使用进程管理器启动cron:https://docs.docker.com/articles/using_supervisord/,或者您可以转到hacky根目录并在后台启动cron。 –

+0

(在后台启动cron,只需在该行的末尾添加一个&) –