public IProcess Run(ProcessRunSpec runSpec)
        {
            Guid processKey = Guid.NewGuid();

            var defaultEnvironmentBlock = EnvironmentBlock.CreateSystemDefault();
            var environment = defaultEnvironmentBlock.Merge(runSpec.Environment).ToDictionary();

            CreateProcessParams @params = new CreateProcessParams
            {
                key = processKey,
                executablePath = runSpec.ExecutablePath,
                arguments = runSpec.Arguments,
                environment = environment,
                workingDirectory = runSpec.WorkingDirectory
            };

            var processDataCallback = BuildProcessDataCallback(runSpec.OutputCallback, runSpec.ErrorCallback);

            hostClient.SubscribeToProcessData(processKey, processDataCallback);

            var result = hostClient.CreateProcess(@params);
            var process = new ConstrainedProcess(hostClient, processKey, result.id, environment);

            return process;
        }
Ejemplo n.º 2
0
        public IProcess Run(ProcessRunSpec runSpec)
        {
            Guid processKey = Guid.NewGuid();

            var defaultEnvironmentBlock = EnvironmentBlock.CreateSystemDefault();
            var environment             = defaultEnvironmentBlock.Merge(runSpec.Environment).ToDictionary();

            CreateProcessParams @params = new CreateProcessParams
            {
                key              = processKey,
                executablePath   = runSpec.ExecutablePath,
                arguments        = runSpec.Arguments,
                environment      = environment,
                workingDirectory = runSpec.WorkingDirectory
            };

            var processDataCallback = BuildProcessDataCallback(runSpec.OutputCallback, runSpec.ErrorCallback);

            hostClient.SubscribeToProcessData(processKey, processDataCallback);

            var result  = hostClient.CreateProcess(@params);
            var process = new ConstrainedProcess(hostClient, processKey, result.id, environment);

            return(process);
        }
        public ConstrainedProcessTests()
        {
            ProcessKey = Guid.NewGuid();

            HostClient = Substitute.For<IContainerHostClient>();

            OutputCallback = delegate { };
            ErrorCallback = delegate { };

            Process = new ConstrainedProcess(HostClient, ProcessKey, 100, new Dictionary<string, string>());
        }
Ejemplo n.º 4
0
        public ConstrainedProcessTests()
        {
            ProcessKey = Guid.NewGuid();

            HostClient = Substitute.For <IContainerHostClient>();

            OutputCallback = delegate { };
            ErrorCallback  = delegate { };

            Process = new ConstrainedProcess(HostClient, ProcessKey, 100, new Dictionary <string, string>());
        }