Codemaru 1.0.0.0
QR 코드, 모바일 랜딩 페이지, vCard 연락처 저장과 명함 디자인을 한 화면에서 제공하는 디지털 명함 서비스입니다.
로딩중...
검색중...
일치하는것 없음
NginxReloadService.cs
이 파일의 문서화 페이지로 가기
3
5
15{
25
50 public NginxReloadService(IProcessRunner processRunner)
51 {
52 _processRunner = processRunner ?? throw new ArgumentNullException(nameof(processRunner));
53 }
54
87 public async Task<ProcessExecutionResult> ReloadAsync(CertificateMonitorOptions options, CancellationToken cancellationToken)
88 {
89 ArgumentNullException.ThrowIfNull(options);
90
91 ProcessExecutionResult testResult = await _processRunner.RunAsync(
92 options.NginxPath,
93 "-t",
95 TimeSpan.FromSeconds(30),
97 cancellationToken).ConfigureAwait(false);
98
99 if (!testResult.IsSuccess)
100 {
101 return new ProcessExecutionResult
102 {
103 IsSuccess = false,
104 ExitCode = testResult.ExitCode,
105 Output = testResult.Output,
106 Error = testResult.Error,
107 Message = $"nginx config test failed. {testResult.Message}"
108 };
109 }
110
111 ProcessExecutionResult reloadResult = await _processRunner.RunAsync(
112 options.NginxPath,
113 options.NginxReloadArguments,
114 options.NginxWorkingDirectory,
115 TimeSpan.FromSeconds(30),
116 options.MaxCommandOutputChars,
117 cancellationToken).ConfigureAwait(false);
118
119 return new ProcessExecutionResult
120 {
121 IsSuccess = reloadResult.IsSuccess,
122 ExitCode = reloadResult.ExitCode,
123 Output = JoinSections("[nginx -t]", testResult.Output, "[nginx reload]", reloadResult.Output),
124 Error = JoinSections("[nginx -t]", testResult.Error, "[nginx reload]", reloadResult.Error),
125 Message = reloadResult.IsSuccess
126 ? "nginx config test passed and reload completed successfully."
127 : $"nginx config test passed, but reload failed. {reloadResult.Message}"
128 };
129 }
130
179 private static string JoinSections(string firstTitle, string firstValue, string secondTitle, string secondValue)
180 {
181 string first = string.IsNullOrWhiteSpace(firstValue) ? string.Empty : $"{firstTitle}{Environment.NewLine}{firstValue}";
182 string second = string.IsNullOrWhiteSpace(secondValue) ? string.Empty : $"{secondTitle}{Environment.NewLine}{secondValue}";
183 return string.Join(Environment.NewLine, new[] { first, second }.Where(x => !string.IsNullOrWhiteSpace(x)));
184 }
185}
static string JoinSections(string firstTitle, string firstValue, string secondTitle, string secondValue)
async Task< ProcessExecutionResult > ReloadAsync(CertificateMonitorOptions options, CancellationToken cancellationToken)