-
Notifications
You must be signed in to change notification settings - Fork 74
Expand file tree
/
Copy pathLinuxStrategy.cs
More file actions
62 lines (55 loc) · 2.42 KB
/
Copy pathLinuxStrategy.cs
File metadata and controls
62 lines (55 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using GeneralUpdate.Core;
using GeneralUpdate.Core.Configuration;
using GeneralUpdate.Core.Event;
using GeneralUpdate.Core.Pipeline;
namespace GeneralUpdate.Core.Strategy;
public class LinuxStrategy : AbstractStrategy
{
protected override PipelineContext CreatePipelineContext(VersionInfo version, string patchPath)
{
GeneralTracer.Info($"GeneralUpdate.Core.LinuxStrategy.CreatePipelineContext: building context for version={version.Version}, patchPath={patchPath}");
var context = base.CreatePipelineContext(version, patchPath);
return context;
}
protected override PipelineBuilder BuildPipeline(PipelineContext context)
{
GeneralTracer.Info($"GeneralUpdate.Core.LinuxStrategy.BuildPipeline: assembling middleware pipeline. PatchEnabled={_configinfo.PatchEnabled}");
var builder = new PipelineBuilder(context)
.UseMiddleware<HashMiddleware>()
.UseMiddleware<CompressMiddleware>()
.UseMiddlewareIf<PatchMiddleware>(_configinfo.PatchEnabled);
return builder;
}
protected override async Task OnExecuteCompleteAsync()
{
GeneralTracer.Info("GeneralUpdate.Core.LinuxStrategy.OnExecuteComplete: all versions processed, starting application.");
await StartAppAsync();
}
public override async Task StartAppAsync()
{
try
{
var mainAppPath = CheckPath(_configinfo.InstallPath, _configinfo.MainAppName);
if (string.IsNullOrEmpty(mainAppPath))
throw new Exception($"Can't find the app {mainAppPath}!");
GeneralTracer.Info($"GeneralUpdate.Core.LinuxStrategy.StartApp: launching main app={mainAppPath}");
Process.Start(mainAppPath);
GeneralTracer.Info("GeneralUpdate.Core.LinuxStrategy.StartApp: main app launched successfully.");
}
catch (Exception e)
{
GeneralTracer.Error(
"The StartApp method in the GeneralUpdate.Core.LinuxStrategy class throws an exception.", e);
EventManager.Instance.Dispatch(this, new ExceptionEventArgs(e, e.Message));
}
finally
{
GeneralTracer.Info("GeneralUpdate.Core.LinuxStrategy.StartApp: releasing tracer and terminating updater process.");
GeneralTracer.Dispose();
await GracefulExit.CurrentProcessAsync();
}
}
}