fluxy-bot 0.5.38 → 0.5.40
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/cli.js +23 -6
- package/package.json +1 -1
- package/workspace/backend/index.ts +11 -1
package/bin/cli.js
CHANGED
|
@@ -69,8 +69,9 @@ ExecStart=${nodePath} --import tsx/esm ${dataDir}/supervisor/index.ts
|
|
|
69
69
|
Restart=on-failure
|
|
70
70
|
RestartSec=5
|
|
71
71
|
Environment=HOME=${home}
|
|
72
|
-
Environment=NODE_ENV=
|
|
73
|
-
Environment=
|
|
72
|
+
Environment=NODE_ENV=development
|
|
73
|
+
Environment=NODE_PATH=${dataDir}/node_modules
|
|
74
|
+
Environment=PATH=${nodeBinDir}:${dataDir}/node_modules/.bin:/usr/local/bin:/usr/bin:/bin
|
|
74
75
|
StandardOutput=journal
|
|
75
76
|
StandardError=journal
|
|
76
77
|
SyslogIdentifier=fluxy
|
|
@@ -434,7 +435,7 @@ async function init() {
|
|
|
434
435
|
if (hasSystemd) {
|
|
435
436
|
child.removeAllListeners('exit');
|
|
436
437
|
child.kill('SIGTERM');
|
|
437
|
-
await new Promise((r) => setTimeout(r,
|
|
438
|
+
await new Promise((r) => setTimeout(r, 4000));
|
|
438
439
|
const nodePath = process.execPath;
|
|
439
440
|
const realHome = os.homedir();
|
|
440
441
|
const res = spawnSync(process.execPath, [process.argv[1], 'daemon', 'install'], {
|
|
@@ -471,6 +472,21 @@ async function start() {
|
|
|
471
472
|
return init();
|
|
472
473
|
}
|
|
473
474
|
|
|
475
|
+
// If daemon is already running, don't start a second instance
|
|
476
|
+
if (os.platform() === 'linux' && isServiceInstalled() && isServiceActive()) {
|
|
477
|
+
banner();
|
|
478
|
+
const config = JSON.parse(fs.readFileSync(CONFIG_PATH, 'utf-8'));
|
|
479
|
+
console.log(`\n ${c.blue}●${c.reset} Fluxy is already running as a daemon.\n`);
|
|
480
|
+
if (config.relay?.url) {
|
|
481
|
+
console.log(` ${c.dim}URL:${c.reset} ${c.pink}${link(config.relay.url)}${c.reset}`);
|
|
482
|
+
}
|
|
483
|
+
console.log(` ${c.dim}Status:${c.reset} ${c.pink}fluxy daemon status${c.reset}`);
|
|
484
|
+
console.log(` ${c.dim}Logs:${c.reset} ${c.pink}fluxy daemon logs${c.reset}`);
|
|
485
|
+
console.log(` ${c.dim}Restart:${c.reset} ${c.pink}fluxy daemon restart${c.reset}`);
|
|
486
|
+
console.log(` ${c.dim}Stop:${c.reset} ${c.pink}fluxy daemon stop${c.reset}\n`);
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
|
|
474
490
|
const isLinux = os.platform() === 'linux';
|
|
475
491
|
const hasSystemd = isLinux && (() => { try { execSync('systemctl --version', { stdio: 'ignore' }); return true; } catch { return false; } })();
|
|
476
492
|
const needsDaemon = hasSystemd && !isServiceInstalled();
|
|
@@ -512,7 +528,7 @@ async function start() {
|
|
|
512
528
|
if (needsDaemon) {
|
|
513
529
|
child.removeAllListeners('exit');
|
|
514
530
|
child.kill('SIGTERM');
|
|
515
|
-
await new Promise((r) => setTimeout(r,
|
|
531
|
+
await new Promise((r) => setTimeout(r, 4000));
|
|
516
532
|
const nodePath = process.execPath;
|
|
517
533
|
const realHome = os.homedir();
|
|
518
534
|
const res = spawnSync(process.execPath, [process.argv[1], 'daemon', 'install'], {
|
|
@@ -676,8 +692,9 @@ async function update() {
|
|
|
676
692
|
// Auto-restart daemon if installed
|
|
677
693
|
if (os.platform() === 'linux' && isServiceInstalled()) {
|
|
678
694
|
try {
|
|
679
|
-
|
|
680
|
-
|
|
695
|
+
const cmd = needsSudo() ? `sudo systemctl restart ${SERVICE_NAME}` : `systemctl restart ${SERVICE_NAME}`;
|
|
696
|
+
execSync(cmd, { stdio: 'inherit' });
|
|
697
|
+
console.log(`\n ${c.blue}✔${c.reset} Daemon restarted with new version.\n`);
|
|
681
698
|
} catch {
|
|
682
699
|
console.log(` ${c.yellow}⚠${c.reset} Could not restart daemon. Run ${c.pink}fluxy daemon restart${c.reset} manually.\n`);
|
|
683
700
|
}
|
package/package.json
CHANGED
|
@@ -37,6 +37,16 @@ app.use((_req, res) => {
|
|
|
37
37
|
res.status(404).json({ error: 'Not found' });
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
-
app.listen(PORT, () => {
|
|
40
|
+
const server = app.listen(PORT, () => {
|
|
41
41
|
console.log(`[backend] Listening on port ${PORT}`);
|
|
42
42
|
});
|
|
43
|
+
|
|
44
|
+
server.on('error', (err: NodeJS.ErrnoException) => {
|
|
45
|
+
console.error(`[backend] Server error: ${err.message}`);
|
|
46
|
+
process.exit(1);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// Keep process alive — prevent exit on unhandled rejection
|
|
50
|
+
process.on('unhandledRejection', (err) => {
|
|
51
|
+
console.error('[backend] Unhandled rejection:', err);
|
|
52
|
+
});
|