Пример #1
0
        /// <inheritdoc />
        public async Task <BoolResult> ShutdownAsync(Context context)
        {
            ShutdownStarted = true;
            context.Debug($"Stopping service process {_process.Id} for scenario {_scenario}");

            await Task.Run(() =>
            {
                IpcUtilities.SetShutdown(_scenario);

                if (!_process.WaitForExit(_waitForExitTimeoutMs))
                {
                    context.Warning("Service process failed to exit, killing hard");
                    try
                    {
                        _process.Kill();
                    }
                    catch (InvalidOperationException)
                    {
                        // the process may have exited,
                        // in this case ignore the exception
                    }
                }
            });

            ShutdownCompleted = true;

            if (_process.ExitCode.HasValue && (_process.ExitCode != 0 || _process.GetStdErr().Length != 0))
            {
                return(new BoolResult($"Process exited with code {_process.ExitCode}. Command line args: {_args}. StdErr: {_process.GetStdErr()} StdOut: {_process.GetStdOut()}"));
            }

            return(BoolResult.Success);
        }
Пример #2
0
 private void SafeKillProcess()
 {
     try
     {
         if (!_process.HasExited)
         {
             _process?.Kill();
             _process?.WaitForExit(5000);
         }
     }
     catch (InvalidOperationException)
     {
     }
 }
Пример #3
0
 private void SafeKillProcess()
 {
     try
     {
         if (!_process.HasExited)
         {
             _process.Kill();
             _process.WaitForExit(5000);
             _logger.Debug("The redis process is killed");
         }
     }
     catch (InvalidOperationException)
     {
     }
 }