0
我正試圖在coreos上配置一個看門狗。 服務是這樣的。爲什麼看門狗不踢?
[Unit]
Description=Watchdog example service
[Service]
Type=notify
Environment=NOTIFY_SOCKET=/run/%p.sock
Environment=WATCHDOG_USEC=1000000
ExecStartPre=-/usr/bin/docker kill %p
ExecStartPre=-/usr/bin/docker rm %p
ExecStart=/usr/libexec/sdnotify-proxy /run/%p.sock /usr/bin/docker run \
--env=NOTIFY_SOCKET=/run/%p.sock \
-v /run:/run \
--name %p pranav93/test_watchdogged python hello.py
ExecStop=/usr/bin/docker stop %p
WatchdogSec=1
[Install]
WantedBy=multi-user.target
蟒蛇文件hello.py
是一樣的東西,
print 'Hello, in hello.py'
print 'ready sending'
x = sd_notifyd({'READY':1})
print str(x)
print 'watchdog sending'
x = sd_notifyd({'WATCHDOG':1})
print str(x)
print os.environ.get('WATCHDOG_USEC', None)
print 'lol, wait now for sometime'
import time
for i in range(3):
print i
time.sleep(1)
print 'finished'
雖然我不發送WATCHDOG=1
坪至sysd
,它仍然不是它停止,服務沒有動它「失敗」的狀態。它背後的原因是什麼? 原木是
Oct 06 09:33:19 core-01 systemd[1]: Starting Watchdog example service...
Oct 06 09:33:19 core-01 docker[2779]: watchdogged
Oct 06 09:33:19 core-01 docker[2790]: watchdogged
Oct 06 09:33:19 core-01 sdnotify-proxy[2800]: True
Oct 06 09:33:22 core-01 sdnotify-proxy[2800]: ready sending
Oct 06 09:33:22 core-01 sdnotify-proxy[2800]: <socket._socketobject object at 0x7fa3cc3c2440>
Oct 06 09:33:22 core-01 sdnotify-proxy[2800]: 1
Oct 06 09:33:22 core-01 sdnotify-proxy[2800]: watchdog sending
Oct 06 09:33:22 core-01 sdnotify-proxy[2800]: <socket._socketobject object at 0x7fa3cc3c2440>
Oct 06 09:33:22 core-01 sdnotify-proxy[2800]: 1
Oct 06 09:33:22 core-01 sdnotify-proxy[2800]: None
Oct 06 09:33:22 core-01 sdnotify-proxy[2800]: lol, wait now for someyime
Oct 06 09:33:22 core-01 sdnotify-proxy[2800]: 0
Oct 06 09:33:22 core-01 sdnotify-proxy[2800]: 1
Oct 06 09:33:22 core-01 sdnotify-proxy[2800]: 2
Oct 06 09:33:22 core-01 sdnotify-proxy[2800]: finished
Oct 06 09:33:22 core-01 docker[2851]: watchdogged
Oct 06 09:33:22 core-01 systemd[1]: Started Watchdog example service.
此外,你不應該甚至需要NOTIFY_SOCKET和WATCHDOG_USEC傳遞 - systemd應該設置這些環境變量爲你當你有WatchdogSec設置。 –