Exemplo n.º 1
0
        public string GetArguments(WorkerCreateContext context)
        {
            var argumentsBuilder = context.Arguments.ExecutableArguments.Aggregate(new StringBuilder(), MergeArguments);

            argumentsBuilder.AppendFormat(" \"{0}\"", context.Arguments.WorkerPath);
            context.Arguments.WorkerArguments.Aggregate(argumentsBuilder, MergeArguments);
            argumentsBuilder.AppendFormat(" --host {0} --port {1} --workerId {2} --requestId {3}",
                                          context.ServerUri.Host, context.ServerUri.Port, context.WorkerId, context.RequestId);
            return(argumentsBuilder.ToString());
        }
Exemplo n.º 2
0
        public virtual Process CreateWorkerProcess(WorkerCreateContext 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
            });
        }
Exemplo n.º 3
0
        // start worker process and wait for an rpc start stream response
        internal void StartWorker()
        {
            _startSubscription = _inboundWorkerEvents.Where(msg => msg.MessageType == MsgType.StartStream)
                                 .Timeout(timeoutStart)
                                 .Take(1)
                                 .Subscribe(InitWorker, HandleWorkerError);

            var workerContext = new WorkerCreateContext()
            {
                RequestId        = Guid.NewGuid().ToString(),
                WorkerId         = _workerId,
                Arguments        = _workerConfig.Arguments,
                WorkingDirectory = _scriptConfig.RootScriptPath,
                ServerUri        = _serverUri,
            };

            _process = _processFactory.CreateWorkerProcess(workerContext);
            StartProcess(_workerId, _process);
        }