Thank you for your reply!
Sometimes there are error messages, e.g.
2023/11/10 09:59:48 Error in Watcher Error channel: CancelIo: The handle is invalid.
2023/11/10 09:59:48 Error in Watcher Error channel: CloseHandle: The handle is invalid.
I don’t know whether this is related to the issue.
I did some additional testing and it seems that on Windows, shutdown is done gracefully, while reload is not.
During Telegraf shutdown, Python detects a KeyboardInterrupt, and optionally, Python can also detect the shutdown with win32api.SetConsoleCtrlHandler
. I can clean up and exit, all is good. If the cleanup takes more than 5 seconds, Python gets killed - also good.
During Telegraf reload, Python detects nothing, so it seems Telegraf doesn’t send any signals. After 5 (lost) seconds, Python gets killed and then Telegraf restarts.
My issue is that I don’t want the 5 lost seconds, but it does seem like it is a part of a bigger bug, namely that Telegraf reload (on Windows) does not follow the same clean shutdown procedure for execd, as Telegraf shutdown does.
Full log, Python and Telegraf output together:
2023-11-10T08:59:37Z I! Loading config: telegraf.conf
2023-11-10T08:59:37Z I! Starting Telegraf 1.28.3 brought to you by InfluxData the makers of InfluxDB
2023-11-10T08:59:37Z I! Available plugins: 240 inputs, 9 aggregators, 29 processors, 24 parsers, 59 outputs, 5 secret-stores
2023-11-10T08:59:37Z I! Config watcher started
2023-11-10T08:59:37Z I! Loaded inputs: execd
2023-11-10T08:59:37Z I! Loaded aggregators:
2023-11-10T08:59:37Z I! Loaded processors:
2023-11-10T08:59:37Z I! Loaded secretstores:
2023-11-10T08:59:37Z I! Loaded outputs: file
2023-11-10T08:59:37Z I! [agent] Config: Interval:10s, Quiet:false, Flush Interval:10s
2023-11-10T08:59:37Z I! [inputs.execd] Starting process: python.exe [hangup.py]
Python:
2023-11-10T08:59:37.313398 Starting indefinite loop
Manual action:
Change config file comment
2023-11-10T08:59:48Z I! Config file modified
2023-11-10T08:59:48Z I! Reloading Telegraf config
2023/11/10 09:59:48 Error in Watcher Error channel: CancelIo: The handle is invalid.
2023/11/10 09:59:48 Error in Watcher Error channel: CloseHandle: The handle is invalid.
2023-11-10T08:59:53Z I! [inputs.execd] Process python.exe shut down
2023-11-10T08:59:53Z I! [agent] Hang on, flushing any cached metrics before shutdown
2023-11-10T08:59:53Z I! [agent] Stopping running outputs
2023-11-10T08:59:53Z I! Loading config: telegraf.conf
2023-11-10T08:59:53Z I! Config watcher started
2023-11-10T08:59:53Z I! Starting Telegraf 1.28.3 brought to you by InfluxData the makers of InfluxDB
2023-11-10T08:59:53Z I! Available plugins: 240 inputs, 9 aggregators, 29 processors, 24 parsers, 59 outputs, 5 secret-stores
2023-11-10T08:59:53Z I! Loaded inputs: execd
2023-11-10T08:59:53Z I! Loaded aggregators:
2023-11-10T08:59:53Z I! Loaded processors:
2023-11-10T08:59:53Z I! Loaded secretstores:
2023-11-10T08:59:53Z I! Loaded outputs: file
2023-11-10T08:59:53Z I! [agent] Config: Interval:10s, Quiet:false, Flush Interval:10s
2023-11-10T08:59:53Z I! [inputs.execd] Starting process: python.exe [hangup.py]
Python:
2023-11-10T08:59:53.159398 Starting indefinite loop
Manual action:
Terminate Telegraf with Control-C
Python:
2023-11-10T09:00:08.390532 win32api.SetConsoleCtrlHandler triggered, signal: 0. Sleeping for 2 seconds.
2023-11-10T09:00:10.391763 Now really exiting
2023-11-10T09:00:10.396079 Keyboardinterrupt detected, exiting
2023-11-10T09:00:10Z I! [inputs.execd] Process python.exe shut down
2023-11-10T09:00:10Z I! [agent] Hang on, flushing any cached metrics before shutdown
2023-11-10T09:00:10Z I! [agent] Stopping running outputs
I’ll file a bug report for this next week, unless you can spot something I’m missing.