2015-06-06 46 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,只需在該行的末尾添加一個&) –