private void OnProcessExited(object sender, EventArgs e) { string exceptionMessage = string.Join(",", _processStdErrDataQueue.Where(s => !string.IsNullOrEmpty(s))); bool workerErrorHandled = false; try { if (_process.ExitCode != 0) { var processExitEx = new LanguageWorkerProcessExitException($"{_process.StartInfo.FileName} exited with code {_process.ExitCode}\n {exceptionMessage}"); HandleWorkerError(processExitEx); workerErrorHandled = true; } else { _process.WaitForExit(); _process.Close(); } } catch (Exception ex) { if (!workerErrorHandled) { var processExitEx = new LanguageWorkerProcessExitException($"Worker process is not attached. {exceptionMessage}", ex); HandleWorkerError(processExitEx); } } }
private void OnProcessExited(object sender, EventArgs e) { if (_disposing) { // No action needed return; } string exceptionMessage = string.Join(",", _processStdErrDataQueue.Where(s => !string.IsNullOrEmpty(s))); try { if (_process.ExitCode != 0) { var processExitEx = new LanguageWorkerProcessExitException($"{_process.StartInfo.FileName} exited with code {_process.ExitCode}\n {exceptionMessage}"); processExitEx.ExitCode = _process.ExitCode; HandleWorkerError(processExitEx); } else { _process.WaitForExit(); _process.Close(); } } catch (Exception) { // ignore process is already disposed } }
internal void HandleWorkerProcessExitError(LanguageWorkerProcessExitException langExc) { // The subscriber of WorkerErrorEvent is expected to Dispose() the errored channel if (langExc != null && langExc.ExitCode != -1) { _workerProcessLogger.LogDebug(langExc, $"Language Worker Process exited.", _process.StartInfo.FileName); _eventManager.Publish(new WorkerErrorEvent(_runtime, _workerId, langExc)); } }
internal override void HandleWorkerProcessExitError(LanguageWorkerProcessExitException langExc) { // The subscriber of WorkerErrorEvent is expected to Dispose() the errored channel if (langExc != null && langExc.ExitCode != -1) { _workerProcessLogger.LogDebug(langExc, $"Language Worker Process exited.", _workerProcessArguments.ExecutablePath); _eventManager.Publish(new WorkerErrorEvent(_runtime, _workerId, langExc)); } }
internal void HandleWorkerError(Exception exc) { LanguageWorkerProcessExitException langExc = exc as LanguageWorkerProcessExitException; // The subscriber of WorkerErrorEvent is expected to Dispose() the errored channel if (langExc != null && langExc.ExitCode == -1) { _workerChannelLogger.LogDebug(exc, $"Language Worker Process exited.", _process.StartInfo.FileName); } else { _workerChannelLogger.LogError(exc, $"Language Worker Process exited.", _process.StartInfo.FileName); } _eventManager.Publish(new WorkerErrorEvent(_workerConfig.Language, Id, exc)); }
internal abstract void HandleWorkerProcessExitError(LanguageWorkerProcessExitException langExc);