arisa 2.3.21 → 2.3.23
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/bin/arisa.js +4 -0
- package/package.json +1 -1
- package/src/daemon/index.ts +19 -5
- package/src/daemon/lifecycle.ts +5 -0
package/bin/arisa.js
CHANGED
|
@@ -495,6 +495,10 @@ if (isRoot() && arisaUserExists()) {
|
|
|
495
495
|
|
|
496
496
|
// All processes use arisa's data dir (inherited by Daemon → Core)
|
|
497
497
|
process.env.ARISA_DATA_DIR = arisaDataDir;
|
|
498
|
+
|
|
499
|
+
// Permissive umask so files Daemon (root) creates at runtime in the shared
|
|
500
|
+
// data dir are readable/writable by Core (arisa). Safe in Docker containers.
|
|
501
|
+
process.umask(0o000);
|
|
498
502
|
}
|
|
499
503
|
|
|
500
504
|
// Then fall through to normal daemon startup
|
package/package.json
CHANGED
package/src/daemon/index.ts
CHANGED
|
@@ -262,11 +262,25 @@ void autoInstallMissingClis();
|
|
|
262
262
|
// --- Start Core process ---
|
|
263
263
|
startCore();
|
|
264
264
|
|
|
265
|
-
// --- Connect Telegram ---
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
265
|
+
// --- Connect Telegram (with retry for 409 conflict from stale polling sessions) ---
|
|
266
|
+
(async function connectTelegram(maxRetries = 5) {
|
|
267
|
+
for (let attempt = 1; attempt <= maxRetries; attempt++) {
|
|
268
|
+
try {
|
|
269
|
+
await telegram.connect();
|
|
270
|
+
return; // connected — polling continues in background
|
|
271
|
+
} catch (error) {
|
|
272
|
+
const is409 = String(error).includes("409");
|
|
273
|
+
if (is409 && attempt < maxRetries) {
|
|
274
|
+
const wait = attempt * 5;
|
|
275
|
+
log.warn(`Telegram 409 conflict (attempt ${attempt}/${maxRetries}), retrying in ${wait}s...`);
|
|
276
|
+
await new Promise((r) => setTimeout(r, wait * 1000));
|
|
277
|
+
continue;
|
|
278
|
+
}
|
|
279
|
+
log.error(`Telegram connection failed: ${error}`);
|
|
280
|
+
process.exit(1);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
})();
|
|
270
284
|
|
|
271
285
|
// --- Graceful shutdown ---
|
|
272
286
|
function shutdown() {
|
package/src/daemon/lifecycle.ts
CHANGED
|
@@ -15,6 +15,7 @@ import { config } from "../shared/config";
|
|
|
15
15
|
import { createLogger } from "../shared/logger";
|
|
16
16
|
import { attemptAutoFix } from "./autofix";
|
|
17
17
|
import { isRunningAsRoot } from "../shared/ai-cli";
|
|
18
|
+
import { spawnSync } from "child_process";
|
|
18
19
|
import { join } from "path";
|
|
19
20
|
|
|
20
21
|
const log = createLogger("daemon");
|
|
@@ -126,6 +127,10 @@ export function startCore() {
|
|
|
126
127
|
// (tokens, ARISA_DATA_DIR, API keys). We only override HOME/BUN/PATH.
|
|
127
128
|
let cmd: string[];
|
|
128
129
|
if (isRunningAsRoot()) {
|
|
130
|
+
// Ensure arisa owns all data dir files created during Daemon init
|
|
131
|
+
// (encryption keys, DB, PID files, etc.) before Core reads them.
|
|
132
|
+
spawnSync("chown", ["-R", "arisa:arisa", config.arisaDir], { stdio: "ignore" });
|
|
133
|
+
|
|
129
134
|
const bunEnv = "export HOME=/home/arisa && export BUN_INSTALL=/home/arisa/.bun && export PATH=/home/arisa/.bun/bin:$PATH";
|
|
130
135
|
const inner = `${bunEnv} && cd ${config.projectDir} && exec bun --watch ${coreEntry}`;
|
|
131
136
|
cmd = ["su", "arisa", "-s", "/bin/bash", "-c", inner];
|