Service cannot be stopped properly
See original GitHub issueSummary. Describe the expected and actual behavior here.
Steps to reproduce
Created some simple service that runs a console command.
If you need to attach your configuration, please do it pelow:
<service>
<id>service_name</id>
<name>name</name>
<description>some laravel command</description>
<executable>php</executable>
<arguments>%BASE%\artisan queue:work</arguments>
<logmode>rotate</logmode>
<onfailure action="restart" />
</service>
Environment
- WinSW version: v2.9.0 and v2.10.0-v2.10.2
- WinSW package type: NET 4.6.1
- Windows version: Windows Server 2016 Datacenter (Azure)
- Wrapped executable and version: php.exe (7.4.7)
Possible Solution
The problem is exactly the same as #627 and was introduced along the update between v2.9.0 and v.2.10.0.
The exact commit that added the changes is f9e0126cf8baad61e9009b47d04aad2e06c20821 whereas new signal handling added requirements to have a console for WinSW.
Please compare the output for test command in v2.9.0:
E:\<redacted>>winsw test
2020-10-09 11:25:29,527 INFO - Starting php E:\<redacted>\artisan queue:work
2020-10-09 11:25:29,558 INFO - Started process 772
2020-10-09 11:25:30,574 INFO - Stopping <service_name>
2020-10-09 11:25:30,714 INFO - Found child process: 7956 Name: cmd.exe
2020-10-09 11:25:30,824 INFO - Stopping process 7956
2020-10-09 11:25:30,824 INFO - Process 7956 is already stopped
System.ArgumentException: Process with an Id of 7956 is not running.
at System.Diagnostics.Process.GetProcessById(Int32 processId, String machineName)
at winsw.Util.ProcessHelper.StopProcess(Int32 pid, TimeSpan stopTimeout)
2020-10-09 11:25:30,839 INFO - Stopping process 772
2020-10-09 11:25:30,855 INFO - Send SIGINT 772
2020-10-09 11:25:30,855 WARN - SIGINT to 772 failed - Killing as fallback
2020-10-09 11:25:30,855 INFO - Finished <service_name>
Comparing with the output of v.2.10.0 up to v2.10.2:
E:\<redacted>>winsw test
2020-10-09 11:24:45,957 INFO - Starting php E:\<redacted>\artisan queue:work
2020-10-09 11:24:45,973 INFO - Started process 7060
2020-10-09 11:24:47,004 INFO - Stopping <service_name>
2020-10-09 11:24:47,004 INFO - Stopping process 7060
2020-10-09 11:24:47,004 WARN - Failed to attach to console. WinSW is already attached to a console.
2020-10-09 11:24:47,160 INFO - Finished <service_name>
There was error attaching to console and there is no fallback after v2.10.0. Backporting the fix from #643 would also fix this issue for v2.
I am also not sure if it’s safe to kill the parent process first, as the parent process here is also a supervisor to its child process, which I see that in future releases this may be the default and the only behaviour.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
Nice! We should release a new version soon.
Thanks for your prompt reply.