Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release/6.0-staging] Make WindowsServiceLifetime gracefully stop #85661

Merged

Commits on May 2, 2023

  1. Make WindowsServiceLifetime gracefully stop (dotnet#83892)

    * Make WindowsServiceLifetime gracefully stop
    
    WindowsServiceLifetime was not waiting for ServiceBase to stop the service.  As a result
    we would sometimes end the process before notifying service control manager that the service
    had stopped -- resulting in an error in the eventlog and sometimes a service restart.
    
    We also were permitting multiple calls to Stop to occur - through SCM callbacks, and through
    public API.  We must not call SetServiceStatus again once the service is marked as stopped.
    
    * Alternate approach to ensuring we only ever set STATE_STOPPED once.
    
    * Avoid calling ServiceBase.Stop on stopped service
    
    I fixed double-calling STATE_STOPPED in ServiceBase, but this fix will
    not be present on .NETFramework.  Workaround that by avoiding calling
    ServiceBase.Stop when the service has already been stopped by SCM.
    
    * Add tests for WindowsServiceLifetime
    
    These tests leverage RemoteExecutor to avoid creating a separate service
    assembly.
    
    * Respond to feedback and add more tests.
    
    This better integrates with the RemoteExecutor component as well,
    by hooking up the service process and fetching its handle.
    
    This gives us the correct logging and exitcode handling from
    RemoteExecutor.
    
    * Honor Cancellation in StopAsync
    
    * Fix bindingRedirects in RemoteExecutor
    
    * Use Async lambdas for service testing
    
    * Fix issue on Win7 where duplicate service descriptions are disallowed
    
    * Respond to feedback
    
    * Fix comment and add timeout
    ericstj committed May 2, 2023
    Configuration menu
    Copy the full SHA
    06180cc View commit details
    Browse the repository at this point in the history
  2. Fix test condition

    # Conflicts:
    #	src/libraries/Microsoft.Extensions.Hosting.WindowsServices/tests/UseWindowsServiceTests.cs
    ericstj committed May 2, 2023
    Configuration menu
    Copy the full SHA
    90b22bd View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    7e3ad95 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    401845d View commit details
    Browse the repository at this point in the history
  5. Fix WindowsService Tests where RemoteExecutor is unsupported

    # Conflicts:
    #	src/libraries/Microsoft.Extensions.Hosting.WindowsServices/tests/UseWindowsServiceTests.cs
    VSadov authored and ericstj committed May 2, 2023
    Configuration menu
    Copy the full SHA
    1535f09 View commit details
    Browse the repository at this point in the history
  6. Port changes to 6.0 codebase

    ericstj committed May 2, 2023
    Configuration menu
    Copy the full SHA
    3898386 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    760fbbf View commit details
    Browse the repository at this point in the history