我试图在networking和DNS启动并运行后在Debian 8上启动一个init.d守护进程。 这是我正在使用的脚本:
### BEGIN INIT INFO # Provides: local_daemon # Required-Start: $all $local_fs $remote_fs $network $named $time $syslog # Required-Stop: $all $local_fs $remote_fs $network $named $time $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Starts a Daemon. # Description: Starts a custom daemon. ### END INIT INFO
我有几台服务器,这大部分工作。 但是,在某些情况下,调用脚本时DNS尚未准备好。 所以,守护进程在运行时无法连接到例如www.domain.com。 最终,DNS已经准备就绪,但是在脚本运行之后(而不是在运行的时候)。
问题: 如何在调用脚本时强制DNS准备好? 我的假设是,在“Required-Start:”中命名的$负责DNS的设置和准备。 这似乎并非如此。 如何才能强制执行一个脚本,只有当域名parsing(DNS)和networking准备好了?
编辑2017-01-26 :感谢您的反馈。 这是一个现场服务器,我的Linux技能是最好的。 我宁愿不打破的事情,而他们工作正常,否则。 无论如何,我在服务器启动之前rest了20秒,似乎工作正常。 是的,我很清楚这是一个“黑客”:
start() { # wait a while to make sure the network is ready! sleep 20 # run the server ... } case "$1" in start) # starts the server in a separate thread start & ;; stop) # stop: we do nothing special ;; *) ;; esac exit 0