You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've already enable the preshutdown feature and set the preshutdown timeout to 10min. But whenever I restart the system, service will be forcibly killed by system in 2min. It seems that preshutdown timeout does not take effect.
Steps to reproduce
I use a simple service to reproduce this issue. The program will sleep forever when receive the CTRL C signal. The config file is like that:
<service>
<id>MyService</id>
<name>My Sample Service</name>
<description>This service is a simple test example.</description>
<executable>D:\project\winsw-test\x64\Release\winsw-test.exe</executable>
<logmode>rotate</logmode>
<stoptimeout>5 min</stoptimeout>
<preshutdown>true</preshutdown>
<preshutdownTimeout>10 min</preshutdownTimeout>
</service>
When I stop the service normally, it will be killed by winsw and exited:
2024-04-18T17:53:32.010 INFO console - Stopping service 'My Sample Service (MyService)'...
2024-04-18T17:53:32.040 INFO service - Stopping MyService
2024-04-18T17:53:32.042 DEBUG service - ProcessKill 6560
2024-04-18T17:58:31.579 INFO service - Child process 'winsw-test (6560)' terminated.
2024-04-18T17:58:31.599 INFO service - Finished MyService
2024-04-18T17:58:31.599 INFO service - Service stopped successfully.
2024-04-18T17:58:31.699 INFO console - Service 'My Sample Service (MyService)' stopped successfully.
But when I restart the system, it will not be killed by winsw. It seems like that winsw is forcibly killed by system and does not have time to send CTRL C signal to my test program:
2024-04-18T17:59:48.285 INFO service - Stopping MyService
2024-04-18T17:59:48.288 DEBUG service - ProcessKill 9912
2024-04-18T18:03:11.355 DEBUG console - Starting WinSW in service mode.
2024-04-18T18:03:11.418 INFO service - Starting D:\project\winsw-test\x64\Release\winsw-test.exe
2024-04-18T18:03:11.477 INFO service - Started process winsw-test (7712).
2024-04-18T18:03:11.505 INFO service - Service started successfully.
Check the Windows event log, also find an error for SCM service did not shutdown properly after receiving a preshutdown control(also see this error in #614)
I check the winsw source code and find out that winsw doesn't update the checkpoint value when stopping the service. So I try to add a new thread to increase the checkpoint value every 30s during service stopping based on https://github.com/winsw/winsw/tree/v3.0.0-alpha.11. Using the fixed winsw, the issue is gone.
The text was updated successfully, but these errors were encountered:
I've already enable the preshutdown feature and set the preshutdown timeout to 10min. But whenever I restart the system, service will be forcibly killed by system in 2min. It seems that preshutdown timeout does not take effect.
Steps to reproduce
I use a simple service to reproduce this issue. The program will sleep forever when receive the CTRL C signal. The config file is like that:
When I stop the service normally, it will be killed by winsw and exited:
But when I restart the system, it will not be killed by winsw. It seems like that winsw is forcibly killed by system and does not have time to send CTRL C signal to my test program:
Check the Windows event log, also find an error for SCM
service did not shutdown properly after receiving a preshutdown control
(also see this error in #614)Environment
Possible Solution
According to this doc https://learn.microsoft.com/en-us/archive/msdn-magazine/2008/launch/windows-with-c-windows-services-enhancements, service must update checkpoint value when preshutdown:
I check the winsw source code and find out that winsw doesn't update the checkpoint value when stopping the service. So I try to add a new thread to increase the checkpoint value every 30s during service stopping based on https://github.com/winsw/winsw/tree/v3.0.0-alpha.11. Using the fixed winsw, the issue is gone.
The text was updated successfully, but these errors were encountered: