public Task StartWorkerProcessAsync() { _startSubscription = _inboundWorkerEvents.Where(msg => msg.MessageType == MsgType.StartStream) .Timeout(TimeSpan.FromSeconds(LanguageWorkerConstants.ProcessStartTimeoutSeconds)) .Take(1) .Subscribe(SendWorkerInitRequest, HandleWorkerError); var workerContext = new WorkerContext() { RequestId = Guid.NewGuid().ToString(), MaxMessageLength = LanguageWorkerConstants.DefaultMaxMessageLengthBytes, WorkerId = _workerId, Arguments = _workerConfig.Arguments, WorkingDirectory = _rootScriptPath, ServerUri = _serverUri, }; _process = _processFactory.CreateWorkerProcess(workerContext); StartProcess(); _processRegistry?.Register(_process); _state = LanguageWorkerChannelState.Initializing; return(Task.CompletedTask); }
internal LanguageWorkerProcess(string runtime, string workerId, string rootScriptPath, Uri serverUri, WorkerProcessArguments workerProcessArguments, IScriptEventManager eventManager, IWorkerProcessFactory processFactory, IProcessRegistry processRegistry, ILogger workerProcessLogger, ILanguageWorkerConsoleLogSource consoleLogSource) { _runtime = runtime; _workerId = workerId; _processFactory = processFactory; _processRegistry = processRegistry; _workerProcessLogger = workerProcessLogger; _consoleLogSource = consoleLogSource; _eventManager = eventManager; var workerContext = new WorkerContext() { RequestId = Guid.NewGuid().ToString(), MaxMessageLength = LanguageWorkerConstants.DefaultMaxMessageLengthBytes, WorkerId = _workerId, Arguments = workerProcessArguments, WorkingDirectory = rootScriptPath, ServerUri = serverUri, }; _process = _processFactory.CreateWorkerProcess(workerContext); }
public string GetArguments(WorkerContext context) { var argumentsBuilder = context.Arguments.ExecutableArguments.Aggregate(new StringBuilder(), MergeArguments); if (!string.IsNullOrEmpty(context.Arguments.WorkerPath)) { argumentsBuilder.AppendFormat(" \"{0}\"", context.Arguments.WorkerPath); } context.Arguments.WorkerArguments.Aggregate(argumentsBuilder, MergeArguments); argumentsBuilder.Append(context.GetFormatedArguments()); return(argumentsBuilder.ToString()); }
public string GetArguments(WorkerContext context) { var argumentsBuilder = context.Arguments.ExecutableArguments.Aggregate(new StringBuilder(), MergeArguments); if (!string.IsNullOrEmpty(context.Arguments.WorkerPath)) { argumentsBuilder.AppendFormat(" \"{0}\"", context.Arguments.WorkerPath); } context.Arguments.WorkerArguments.Aggregate(argumentsBuilder, MergeArguments); argumentsBuilder.AppendFormat(" --host {0} --port {1} --workerId {2} --requestId {3} --grpcMaxMessageLength {4}", context.ServerUri.Host, context.ServerUri.Port, context.WorkerId, context.RequestId, context.MaxMessageLength); return(argumentsBuilder.ToString()); }
public virtual Process CreateWorkerProcess(WorkerContext context) { var startInfo = new ProcessStartInfo(context.Arguments.ExecutablePath) { RedirectStandardOutput = true, RedirectStandardError = true, CreateNoWindow = true, UseShellExecute = false, ErrorDialog = false, WorkingDirectory = context.WorkingDirectory, Arguments = GetArguments(context), }; return(new Process { StartInfo = startInfo }); }
public void StartWorkerProcess() { _startSubscription = _inboundWorkerEvents.Where(msg => msg.MessageType == MsgType.StartStream) .Timeout(processStartTimeout) .Take(1) .Subscribe(SendWorkerInitRequest, HandleWorkerError); var workerContext = new WorkerContext() { RequestId = Guid.NewGuid().ToString(), MaxMessageLength = LanguageWorkerConstants.DefaultMaxMessageLengthBytes, WorkerId = _workerId, Arguments = _workerConfig.Arguments, WorkingDirectory = _rootScriptPath, ServerUri = _serverUri, }; _process = _processFactory.CreateWorkerProcess(workerContext); StartProcess(); _processRegistry?.Register(_process); }