Archived
fix: restart web/UI services before sessiond in restart commands
Running the suggested restart command from a PI WEB terminal kills the command when sessiond restarts, so services listed after sessiond were never restarted. Restart web/UI first in both the updates plugin's suggested command and `pi-web restart` (systemd and launchd).
This commit is contained in:
@@ -71,7 +71,7 @@ describe("PI WEB status", () => {
|
||||
|
||||
const status = await getPiWebStatus(daemon);
|
||||
|
||||
expect(status.commands.restart).toBe("systemctl --user restart pi-web-sessiond.service pi-web-ui-dev.service");
|
||||
expect(status.commands.restart).toBe("systemctl --user restart pi-web-ui-dev.service pi-web-sessiond.service");
|
||||
expect(status.commands.restartWeb).toBe("systemctl --user restart pi-web-ui-dev.service");
|
||||
expect(status.commands.restartSessiond).toBe("systemctl --user restart pi-web-sessiond.service");
|
||||
expect(status.messages.find((message) => message.id === "sessiond-stale")?.command).toBe("systemctl --user restart pi-web-sessiond.service");
|
||||
|
||||
@@ -58,6 +58,10 @@ const serviceRefs: Record<ServiceId, NativeServiceRef> = {
|
||||
};
|
||||
|
||||
const startServiceOrder: ServiceId[] = ["sessiond", "web", "uiDev"];
|
||||
// Restart web/UI before sessiond: when the restart command runs in a pi-web
|
||||
// terminal (owned by sessiond), restarting sessiond kills the command, so any
|
||||
// services listed after it would never be restarted.
|
||||
const restartServiceOrder: ServiceId[] = ["web", "uiDev", "sessiond"];
|
||||
|
||||
interface PackageInfo {
|
||||
name: string;
|
||||
@@ -430,7 +434,7 @@ async function nativeServiceCommands(): Promise<NativeServiceCommands> {
|
||||
if (installed.size === 0) return {};
|
||||
const web = installedServiceRefs(installed, ["web", "uiDev"]);
|
||||
const sessiond = installedServiceRefs(installed, ["sessiond"]);
|
||||
const restartable = web.length === 0 ? [] : installedServiceRefs(installed);
|
||||
const restartable = web.length === 0 ? [] : installedServiceRefs(installed, restartServiceOrder, restartServiceOrder);
|
||||
const status = installedServiceRefs(installed);
|
||||
return {
|
||||
...(restartable.length === 0 ? {} : { restart: restartNativeServicesCommand(backend, restartable) }),
|
||||
@@ -450,8 +454,8 @@ function installedServiceIds(backend: NativeServiceBackendKind): Set<ServiceId>
|
||||
return new Set(startServiceOrder.filter((id) => existsSync(serviceFilePath(backend, serviceRefs[id]))));
|
||||
}
|
||||
|
||||
function installedServiceRefs(installed: Set<ServiceId>, candidates: ServiceId[] = startServiceOrder): NativeServiceRef[] {
|
||||
return startServiceOrder.filter((id) => candidates.includes(id) && installed.has(id)).map((id) => serviceRefs[id]);
|
||||
function installedServiceRefs(installed: Set<ServiceId>, candidates: ServiceId[] = startServiceOrder, order: ServiceId[] = startServiceOrder): NativeServiceRef[] {
|
||||
return order.filter((id) => candidates.includes(id) && installed.has(id)).map((id) => serviceRefs[id]);
|
||||
}
|
||||
|
||||
function serviceFilePath(backend: NativeServiceBackendKind, ref: NativeServiceRef): string {
|
||||
|
||||
Reference in New Issue
Block a user