question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Service cannot be stopped properly

See original GitHub issue

Summary. 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:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
nxtncommented, Oct 9, 2020

Nice! We should release a new version soon.

0reactions
itsnotvalidcommented, Oct 9, 2020

Thanks for your prompt reply.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Stopping a windows service when the stop option is grayed ...
Open "services.msc" from command / Windows RUN. · Find the service (which is greyed out). · Double click on that service and go...
Read more >
Unable to Stop Service The operation could not be ...
1. Open the Control Panel. · 2. Choose System and Security and then choose Administrative Tools. · 3. Open the Services icon. ·...
Read more >
Manually stopped service is not properly stopped
Now the server.service was still running in the loaded deactivating stop state where it could not restart for some reason. I let the...
Read more >
Not able to stop Windows service
1 Answer. This message simply means the service did not communicate with the Service Control Manager within the amount of time permitted in...
Read more >
Fix: Windows Update Service could not be Stopped
This problem appears when users are unable to stop the Windows Update Service using the Services tool or Command Prompt.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found