fluxy-bot 0.9.3 → 0.9.4

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 CHANGED
@@ -1229,7 +1229,10 @@ async function update() {
1229
1229
 
1230
1230
  console.log(` ${c.dim}v${currentVersion} → v${latest.version}${c.reset}\n`);
1231
1231
 
1232
- const daemonWasRunning = isDaemonInstalled() && isDaemonActive();
1232
+ // When triggered by the supervisor (FLUXY_SELF_UPDATE=1), skip daemon stop/restart —
1233
+ // the supervisor will exit after we finish, and the daemon manager restarts it.
1234
+ const selfUpdate = !!process.env.FLUXY_SELF_UPDATE;
1235
+ const daemonWasRunning = !selfUpdate && isDaemonInstalled() && isDaemonActive();
1233
1236
 
1234
1237
  const steps = [
1235
1238
  'Downloading update',
@@ -1264,6 +1267,7 @@ async function update() {
1264
1267
  stepper.advance();
1265
1268
 
1266
1269
  // Stop daemon AFTER download succeeds — minimizes downtime
1270
+ // Skipped during self-update (supervisor handles restart via process exit)
1267
1271
  if (daemonWasRunning) {
1268
1272
  try {
1269
1273
  if (PLATFORM === 'darwin') {
@@ -1350,7 +1354,7 @@ async function update() {
1350
1354
  // Clean up
1351
1355
  fs.rmSync(tmpDir, { recursive: true, force: true });
1352
1356
 
1353
- // Restart daemon if it was running
1357
+ // Restart daemon if it was running (skipped during self-update)
1354
1358
  if (daemonWasRunning) {
1355
1359
  try {
1356
1360
  if (PLATFORM === 'darwin') {
@@ -1376,6 +1380,12 @@ async function update() {
1376
1380
  console.log('');
1377
1381
  }
1378
1382
 
1383
+ // During self-update, supervisor handles restart — just exit cleanly
1384
+ if (selfUpdate) {
1385
+ console.log(` Files updated — supervisor will restart with new version.\n`);
1386
+ return;
1387
+ }
1388
+
1379
1389
  if (daemonWasRunning) {
1380
1390
  if (isDaemonActive()) {
1381
1391
  console.log(` ${c.blue}✔${c.reset} Daemon restarted with new version.\n`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fluxy-bot",
3
- "version": "0.9.3",
3
+ "version": "0.9.4",
4
4
  "releaseNotes": [
5
5
  "Fixing auto update",
6
6
  "2. ",
@@ -779,7 +779,10 @@ export async function startSupervisor() {
779
779
  let pendingBackendRestart = false; // Set when file watcher fires during agent turn
780
780
  let pendingUpdate = false; // Set when .update file is created during agent turn
781
781
 
782
- // Run fluxy update in a detached process so it survives daemon stop/restart
782
+ // Run fluxy update as a child process.
783
+ // FLUXY_SELF_UPDATE=1 tells bin/cli.js to skip daemon stop/restart —
784
+ // the supervisor exits after the update finishes, and systemd (Restart=on-failure)
785
+ // or launchd (KeepAlive.SuccessfulExit=false) restarts us with the new code.
783
786
  function runDeferredUpdate() {
784
787
  const cliPath = path.join(PKG_DIR, 'bin', 'cli.js');
785
788
  const updateLog = path.join(DATA_DIR, 'update.log');
@@ -787,19 +790,18 @@ export async function startSupervisor() {
787
790
  try {
788
791
  const logFd = fs.openSync(updateLog, 'w');
789
792
  const child = cpSpawn(process.execPath, [cliPath, 'update'], {
790
- detached: true,
791
793
  stdio: ['ignore', logFd, logFd],
792
- env: { ...process.env },
794
+ env: { ...process.env, FLUXY_SELF_UPDATE: '1' },
793
795
  });
794
796
  child.on('exit', (code) => {
795
797
  try { fs.closeSync(logFd); } catch {}
796
798
  if (code === 0) {
797
- log.ok('Update process completed successfully');
799
+ log.ok('Update completed — restarting with new version...');
800
+ process.exit(1); // non-zero triggers daemon manager to restart us
798
801
  } else {
799
802
  log.error(`Update process exited with code ${code} — see ${updateLog}`);
800
803
  }
801
804
  });
802
- child.unref();
803
805
  } catch (err) {
804
806
  log.error(`Deferred update failed: ${err instanceof Error ? err.message : err}`);
805
807
  }