GetCommandLineArgs() public method

Create the command line arguments to match this configuration.
public GetCommandLineArgs ( LocalServerConfiguration? localContentServerConfiguration = null, string? scenario = null, bool logAutoFlush = false ) : string
localContentServerConfiguration LocalServerConfiguration?
scenario string?
logAutoFlush bool
return string
Beispiel #1
0
        /// <inheritdoc />
        public async Task <BoolResult> StartupAsync(Context context)
        {
            StartupStarted = true;
            BoolResult result = BoolResult.Success;

            context.Debug("Starting service process");

            await Task.Run(() =>
            {
                AbsolutePath appExeDirPath = new AbsolutePath(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
                var appExePath             = appExeDirPath / (OperatingSystemHelper.IsUnixOS ? "ContentStoreApp" : "ContentStoreApp.exe");

                _args = _configuration.GetCommandLineArgs(scenario: _scenario);

                context.Debug($"Running cmd=[{appExePath} {_args}]");

                const bool CreateNoWindow = true;
                _process = new ProcessUtility(appExePath.Path, _args, CreateNoWindow);

                _process.Start();

                string processOutput;
                if (_process == null)
                {
                    processOutput = "[Process could not start]";
                    result        = new BoolResult(processOutput);
                }
                else if (CreateNoWindow)
                {
                    if (_process.HasExited)
                    {
                        if (_process.WaitForExit(5000))
                        {
                            throw new InvalidOperationException(_process.GetLogs());
                        }
                        else
                        {
                            throw new InvalidOperationException("Process or either wait handle timed out. " + _process.GetLogs());
                        }
                    }
                    else
                    {
                        processOutput = $"[Process {_process.Id} is still running]";
                    }
                }

                context.Debug("Process output: " + processOutput);
            });

            if (result.Succeeded && !LocalContentServer.EnsureRunning(context, _scenario, _waitForServerReadyTimeoutMs))
            {
                result = new BoolResult($"Failed to detect server ready in separate process for scenario {_scenario}. Process has {(_process.HasExited ? string.Empty : "not")} exited.");
            }

            StartupCompleted = true;
            return(result);
        }
Beispiel #2
0
 /// <nodoc />
 protected virtual string GetCommandLineArgs()
 {
     return(Configuration.GetCommandLineArgs(scenario: Scenario));
 }