Skip to content

Question: How to use ExitCode? #128

Description

@sekmenhuseyin

I want to restart the service if service stopped with an error. I found that you have something called exit code: https://github.com/PeterKottas/DotNetCore.WindowsService/blob/4c0052bef2217c3f6b3ec15a98e23335fc07aa88/Source/PeterKottas.DotNetCore.WindowsService/ExitCode.cs

How can I user it in here:

            ServiceRunner<CMailerService>.Run(config =>
            {                
                config.Service(serviceConfig =>
                {                   
                    serviceConfig.OnStop(service =>
                    {

                       //in here I want to restart the service if exitCode!=0
                        _serviceStoppedMail.SendServiceStoppedMail(ProjectConstants.RestartInfoMail, _lastError);


                        Log.Information("Service {0} is stopping...", name);
                        service.Stop();
                        Log.Information("Service {0} stopped", name);
                    });
                });
            });

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions