|
3 | 3 | using GeneralUpdate.Bowl; |
4 | 4 |
|
5 | 5 | /// <summary> |
6 | | -/// Bowl crash daemon integration. |
| 6 | +/// 【Skill 参考】Bowl 崩溃守护 |
7 | 7 | /// |
8 | | -/// Bowl monitors whether the main application starts normally after an upgrade. |
9 | | -/// If a crash is detected, it captures a dump, exports diagnostics, |
10 | | -/// and optionally restores the previous version from backup. |
| 8 | +/// v10.5.0-beta.4 中 Bowl 使用 BowlContext 配置,支持 LaunchAsync 方法。 |
11 | 9 | /// |
12 | 10 | /// NuGet: dotnet add package GeneralUpdate.Bowl --version 10.5.0-beta.4 |
13 | | -/// Note: Reference only GeneralUpdate.Bowl (it transitively includes Core). |
14 | | -/// Do NOT reference GeneralUpdate.Core separately when using Bowl. |
15 | | -/// |
16 | | -/// Platform prerequisites: |
17 | | -/// - Windows: Sysinternals procdump.exe is auto-bundled via Bowl NuGet package |
18 | | -/// - Linux: Requires procdump installed (sudo apt install procdump) |
19 | 11 | /// </summary> |
20 | 12 | public static class BowlIntegration |
21 | 13 | { |
22 | 14 | public static async Task RunBowlAsync() |
23 | 15 | { |
24 | | - // Configure the surveillance context |
25 | 16 | var context = new BowlContext |
26 | 17 | { |
27 | | - // Process to monitor (name or PID) |
28 | 18 | ProcessNameOrId = "MyApp.exe", |
29 | | - |
30 | | - // Backup directory path (the version that was running before upgrade) |
| 19 | + DumpFileName = "v1.0.0.0_fail.dmp", |
| 20 | + FailFileName = "v1.0.0.0_fail.json", |
31 | 21 | TargetPath = @"C:\Program Files\MyApp", |
32 | | - |
33 | | - // Version string, used to name dump/crash files |
34 | | - ExtendedField = "1.0.0.1", |
35 | | - |
36 | | - // Generated dump file path |
37 | | - DumpFileName = "1.0.0.1_fail.dmp", |
38 | | - |
39 | | - // Generated crash report file path |
40 | | - FailFileName = "1.0.0.1_fail.json", |
41 | | - |
42 | | - // Where dump/crash files will be written |
43 | | - FailDirectory = @"C:\Program Files\MyApp\fail\1.0.0.1", |
44 | | - |
45 | | - // Backup location (the previous version's backup that can be restored) |
46 | | - BackupDirectory = @"C:\Program Files\MyApp\1.0.0.0", |
47 | | - |
48 | | - // "Upgrade": integrated with update pipeline, auto-restores on crash |
49 | | - // "Normal": standalone monitoring, no restore |
| 22 | + FailDirectory = @"C:\Program Files\MyApp\fail", |
| 23 | + BackupDirectory = @"C:\Program Files\MyApp\backup", |
50 | 24 | WorkModel = "Upgrade", |
51 | | - |
52 | | - // Auto-restore the previous version on crash (only in "Upgrade" mode) |
53 | | - AutoRestore = true, |
54 | | - |
55 | | - // Dump type: Full (0), Mini (1), or Heap (2) |
56 | | - DumpType = DumpType.Full, |
57 | | - |
58 | | - // Timeout for child process (procdump), default 30s |
59 | 25 | TimeoutMs = 30_000, |
60 | | - |
61 | | - // Optional: crash callback for custom handling (logging, telemetry, etc.) |
62 | | - // OnCrash = async (crashInfo, ct) => { ... }, |
| 26 | + AutoRestore = true, |
63 | 27 | }; |
64 | 28 |
|
65 | | - // Apply sensible defaults (Normalize fills in TimeoutMs, WorkModel, DumpType if zero) |
66 | | - context = context.Normalize(); |
67 | | - |
68 | | - // Start surveillance. This blocks until the monitored process exits. |
69 | 29 | var bowl = new Bowl(); |
70 | | - BowlResult result = await bowl.LaunchAsync(context); |
| 30 | + var result = await bowl.LaunchAsync(context); |
71 | 31 |
|
72 | | - Console.WriteLine($""" |
73 | | - [Bowl] 监控完成 |
74 | | - Success: {result.Success} |
75 | | - ExitCode: {result.ExitCode} |
76 | | - DumpCaptured: {result.DumpCaptured} |
77 | | - DumpFilePath: {result.DumpFilePath} |
78 | | - Restored: {result.Restored} |
79 | | - """); |
| 32 | + Console.WriteLine($"[Bowl] 监控完成: Success={result.Success}, DumpCaptured={result.DumpCaptured}"); |
80 | 33 | } |
81 | 34 | } |
0 commit comments