This commit is contained in:
@@ -3,6 +3,9 @@
|
|||||||
namespace ServiceUpdater;
|
namespace ServiceUpdater;
|
||||||
|
|
||||||
public sealed class UpdateWorker(UpdaterConfig config) {
|
public sealed class UpdateWorker(UpdaterConfig config) {
|
||||||
|
|
||||||
|
private int LastExitCode { get; set; }
|
||||||
|
|
||||||
public async IAsyncEnumerable<string> UpdateService(string serviceName) {
|
public async IAsyncEnumerable<string> UpdateService(string serviceName) {
|
||||||
yield return $"Starting update for {serviceName}";
|
yield return $"Starting update for {serviceName}";
|
||||||
|
|
||||||
@@ -10,13 +13,14 @@ public sealed class UpdateWorker(UpdaterConfig config) {
|
|||||||
yield return line;
|
yield return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (LastExitCode != 0)
|
||||||
|
yield break;
|
||||||
|
|
||||||
yield return $"Downloaded changes for {serviceName}";
|
yield return $"Downloaded changes for {serviceName}";
|
||||||
|
|
||||||
await foreach (var line in RunProcess(serviceName, "compose up -d --remove-orphans")) {
|
await foreach (var line in RunProcess(serviceName, "compose up -d --remove-orphans")) {
|
||||||
yield return line;
|
yield return line;
|
||||||
}
|
}
|
||||||
|
|
||||||
yield return $"Successfully updated {serviceName}";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private async IAsyncEnumerable<string> RunProcess(string folder, string arguments) {
|
private async IAsyncEnumerable<string> RunProcess(string folder, string arguments) {
|
||||||
@@ -48,11 +52,12 @@ public sealed class UpdateWorker(UpdaterConfig config) {
|
|||||||
else {
|
else {
|
||||||
var line = await error;
|
var line = await error;
|
||||||
if (line == null) break;
|
if (line == null) break;
|
||||||
yield return "[ERR] " + line;
|
yield return line;
|
||||||
error = process.StandardError.ReadLineAsync();
|
error = process.StandardError.ReadLineAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await process.WaitForExitAsync();
|
await process.WaitForExitAsync();
|
||||||
|
LastExitCode = process.ExitCode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user