Skip to content

Commit 8d5aa04

Browse files
authored
improve logging on startup services failures (#1962)
* catch and log errors when starting hosted services in the MAUI hosted service adapter * don't try to install updates when running a portable app * display a notification in app when the update was successfully installed
1 parent ac1ac8a commit 8d5aa04

8 files changed

Lines changed: 42 additions & 2 deletions

File tree

backend/FwLite/FwLiteMaui/FwLiteMauiKernel.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,22 @@ public void Initialize(IServiceProvider services)
165165
logger.LogInformation("Initializing hosted services");
166166
foreach (var hostedService in hostedServices)
167167
{
168-
_ = Task.Run(() => hostedService.StartAsync(_cts.Token), _cts.Token);
168+
_ = Task.Run(async () =>
169+
{
170+
var hostedServiceName = hostedService.GetType().Name;
171+
try
172+
{
173+
await hostedService.StartAsync(_cts.Token);
174+
}
175+
catch (OperationCanceledException)
176+
{
177+
logger.LogInformation("Hosted service stopped before start completed for service {HostedService}", hostedServiceName);
178+
}
179+
catch (Exception e)
180+
{
181+
logger.LogError(e, "Error starting hosted service {HostedService}", hostedServiceName);;
182+
}
183+
}, _cts.Token);
169184
}
170185
}
171186

backend/FwLite/FwLiteMaui/Platforms/Windows/AppUpdateService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public DateTime LastUpdateCheck
152152
set => preferences.Set(LastUpdateCheckKey, value);
153153
}
154154

155-
public bool SupportsAutoUpdate => true;
155+
public bool SupportsAutoUpdate => !FwLiteMauiKernel.IsPortableApp;
156156

157157
public bool IsOnMeteredConnection()
158158
{

frontend/viewer/src/lib/notifications/NotificationOutlet.svelte

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@
2626
},
2727
label: $t`Download`
2828
});
29+
} else if (event.result == UpdateResult.Success) {
30+
AppNotification.display(
31+
$t`FieldWorks Lite has been updated successfully. Please restart the app to apply the changes.`,
32+
{type: 'info', timeout: 'long'}
33+
);
2934
}
3035
}, {includeLast: true});
3136
</script>

frontend/viewer/src/locales/en.po

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,10 @@ msgstr "Field"
457457
msgid "Field Labels"
458458
msgstr "Field Labels"
459459

460+
#: src/lib/notifications/NotificationOutlet.svelte
461+
msgid "FieldWorks Lite has been updated successfully. Please restart the app to apply the changes."
462+
msgstr "FieldWorks Lite has been updated successfully. Please restart the app to apply the changes."
463+
460464
#: src/project/ProjectDropdown.svelte
461465
#: src/lib/OpenInFieldWorksButton.svelte
462466
#: src/home/HomeView.svelte

frontend/viewer/src/locales/es.po

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,10 @@ msgstr "Campo"
462462
msgid "Field Labels"
463463
msgstr "Etiquetas de campo"
464464

465+
#: src/lib/notifications/NotificationOutlet.svelte
466+
msgid "FieldWorks Lite has been updated successfully. Please restart the app to apply the changes."
467+
msgstr ""
468+
465469
#: src/project/ProjectDropdown.svelte
466470
#: src/lib/OpenInFieldWorksButton.svelte
467471
#: src/home/HomeView.svelte

frontend/viewer/src/locales/fr.po

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,10 @@ msgstr "Champ d'application"
462462
msgid "Field Labels"
463463
msgstr "Étiquettes de champ"
464464

465+
#: src/lib/notifications/NotificationOutlet.svelte
466+
msgid "FieldWorks Lite has been updated successfully. Please restart the app to apply the changes."
467+
msgstr ""
468+
465469
#: src/project/ProjectDropdown.svelte
466470
#: src/lib/OpenInFieldWorksButton.svelte
467471
#: src/home/HomeView.svelte

frontend/viewer/src/locales/id.po

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,10 @@ msgstr "Bidang"
462462
msgid "Field Labels"
463463
msgstr "Label Bidang"
464464

465+
#: src/lib/notifications/NotificationOutlet.svelte
466+
msgid "FieldWorks Lite has been updated successfully. Please restart the app to apply the changes."
467+
msgstr ""
468+
465469
#: src/project/ProjectDropdown.svelte
466470
#: src/lib/OpenInFieldWorksButton.svelte
467471
#: src/home/HomeView.svelte

frontend/viewer/src/locales/ko.po

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,10 @@ msgstr "필드"
462462
msgid "Field Labels"
463463
msgstr "필드 레이블"
464464

465+
#: src/lib/notifications/NotificationOutlet.svelte
466+
msgid "FieldWorks Lite has been updated successfully. Please restart the app to apply the changes."
467+
msgstr ""
468+
465469
#: src/project/ProjectDropdown.svelte
466470
#: src/lib/OpenInFieldWorksButton.svelte
467471
#: src/home/HomeView.svelte

0 commit comments

Comments
 (0)