在繼續執行nosetests
之前,等待postgres
在我的ENTRYPOINT
內完全啓動的最佳方法是什麼?如何在入口點等待postgres的啓動?
現在我已經在我的機器上啓動了大約50秒的啓動時間。所以我只是睡了60秒。這感覺不好,因爲在另一臺機器上運行時這可能不起作用。
ENTRYPOINT \
runuser -l postgres -c '/usr/lib/postgresql/9.3/bin/postgres -D /var/lib/postgresql/9.3/main -c config_file=/etc/postgresql/9.3/main/postgresql.conf & ' && \
sleep 60 && \
nosetests --verbose --cover-erase --with-coverage --cover-package=stalker
這是啓動postgres
的輸出:
2017-02-13 13:46:49.541 UTC [9] LOG: database system was interrupted; last known up at 2017-02-13 12:53:23 UTC
2017-02-13 13:47:37.951 UTC [9] LOG: database system was not properly shut down; automatic recovery in progress
2017-02-13 13:47:37.994 UTC [9] LOG: redo starts at 0/1783EA0
2017-02-13 13:47:37.995 UTC [9] LOG: record with zero length at 0/17841E8
2017-02-13 13:47:37.995 UTC [9] LOG: redo done at 0/17841B8
2017-02-13 13:47:37.995 UTC [9] LOG: last completed transaction was at log time 2017-02-13 12:53:23.731984+00
2017-02-13 13:47:38.384 UTC [9] LOG: MultiXact member wraparound protections are now enabled
2017-02-13 13:47:38.387 UTC [7] LOG: database system is ready to accept connections
2017-02-13 13:47:38.387 UTC [13] LOG: autovacuum launcher started
請,我不明白,這不利於在ENTRYPOINT
運行多個命令的約定。在這種情況下,我有很好的理由這樣做。
您可以運行['pg_isready'](https://www.postgresql.org/docs/current /static/app-pg-isready.html),而返回代碼爲1. –