@danypops/papyrus 0.44.0 → 0.44.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/daemon.ts +10 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@danypops/papyrus",
|
|
3
|
-
"version": "0.44.
|
|
3
|
+
"version": "0.44.1",
|
|
4
4
|
"description": "Daemon-backed graph artifacts, evidence-bearing tasks, rules, skills, and native TUI workflows for Pi",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": ["pi-package"],
|
|
@@ -36,6 +36,6 @@
|
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@danypops/vehicle-core": "^0.10.0",
|
|
38
38
|
"@danypops/vehicle-client": "^0.5.0",
|
|
39
|
-
"@danypops/vehicle-server": "^0.
|
|
39
|
+
"@danypops/vehicle-server": "^0.13.0"
|
|
40
40
|
}
|
|
41
41
|
}
|
package/src/daemon.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { acquireDaemonLock, releaseDaemonLock } from "@danypops/vehicle-server/paths";
|
|
1
3
|
import { PushChannel } from "@danypops/vehicle-server/push-channel";
|
|
2
4
|
import { DAEMON_HOST, DB_OPTIMIZE_INTERVAL_MS, dbPath, WAL_CHECKPOINT_INTERVAL_MS } from "./constants.ts";
|
|
3
5
|
import { clearDaemonPort, daemonStateDir, loadOrCreateToken, writeDaemonPort } from "./daemon-state.ts";
|
|
@@ -28,6 +30,12 @@ const TASK_READ_ONLY_OPERATIONS = new Set([
|
|
|
28
30
|
/** Start the supervised, long-running Papyrus service. */
|
|
29
31
|
export function serveMain(): void {
|
|
30
32
|
const stateDir = daemonStateDir();
|
|
33
|
+
const lockPath = join(stateDir, "daemon.lock");
|
|
34
|
+
const lock = acquireDaemonLock(lockPath);
|
|
35
|
+
if (!lock.acquired) {
|
|
36
|
+
logEvent("info", "already_running", { holderPid: lock.holderPid });
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
31
39
|
const token = loadOrCreateToken(stateDir);
|
|
32
40
|
const service = createPapyrusService(dbPath());
|
|
33
41
|
const pushChannel = new PushChannel({ token });
|
|
@@ -54,6 +62,7 @@ export function serveMain(): void {
|
|
|
54
62
|
});
|
|
55
63
|
if (!server.port) {
|
|
56
64
|
service.close();
|
|
65
|
+
releaseDaemonLock(lockPath);
|
|
57
66
|
throw new Error("Papyrus daemon failed to bind a listener");
|
|
58
67
|
}
|
|
59
68
|
writeDaemonPort(stateDir, server.port);
|
|
@@ -101,6 +110,7 @@ export function serveMain(): void {
|
|
|
101
110
|
clearInterval(reapFocusTimer);
|
|
102
111
|
clearInterval(purgeTrashTimer);
|
|
103
112
|
clearDaemonPort(stateDir);
|
|
113
|
+
releaseDaemonLock(lockPath);
|
|
104
114
|
service.close();
|
|
105
115
|
// .finally() re-throws rather than handling a rejection -- catching it first turns a bare
|
|
106
116
|
// unhandled-rejection warning into a real, queryable shutdown-failure log line.
|