コード例 #1
0
 public ChildProcess(ProcessHostInfo host,
                     string startupArgs,
                     ILogger logger)
 {
     Host        = host;
     StartupArgs = startupArgs;
     _logger     = logger;
     State       = ChildProcessState.Stopped;
     LogHistory  = new ProcessLogQueue <ChildProcessLogHistoryEntry>(50);
 }
コード例 #2
0
 public ChildProcess(Process process,
                     ProcessHostInfo host,
                     string startupArgs,
                     ILogger logger)
 {
     Instance    = process;
     Host        = host;
     StartupArgs = startupArgs;
     _logger     = logger;
     State       = ChildProcessState.Listening;
     LogHistory  = new ProcessLogQueue <ChildProcessLogHistoryEntry>(50);
 }
コード例 #3
0
        public void StartProcess(ProcessHostInfo host)
        {
            if (string.IsNullOrWhiteSpace(host?.Domain))
            {
                return;
            }

            string startupArgs = $"/urls=\"{UrlPrefix.Create("http", host.Domain, host.Port, string.Empty)}\" /process=child";
            var    process     = GetOrphanedProcess(startupArgs, host)
                                 ?? new ChildProcess(host, startupArgs, _logger);

            process.StartTime = DateTime.Now;
            StartProcess(process);
        }
コード例 #4
0
        private ChildProcess GetOrphanedProcess(string startupArgs, ProcessHostInfo host)
        {
            var isRunning = DoHealthCheck($"{host.Domain}:{host.Port}").IsHealthy;

            if (!isRunning)
            {
                return(null);
            }

            var orphanedProcessId = GetOrphanedProcessId($"{host.Domain}:{host.Port}");

            if (!orphanedProcessId.HasValue)
            {
                return(null);
            }

            var orphanedProcess = Process.GetProcessById(orphanedProcessId.Value);

            var orphanedChildProcess = new ChildProcess(orphanedProcess, host, startupArgs, _logger);

            Log($"ORPHANED PROCESS RECLAIMED: Id - {orphanedProcess.Id}, Domain - {host.Domain}:{host.Port}", orphanedChildProcess, ChildProcessLogLevel.Info);

            return(orphanedChildProcess);
        }