fleetbo-cockpit-cli 1.0.29 → 1.0.31
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/cli.js +61 -14
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -761,20 +761,67 @@ else {
|
|
|
761
761
|
console.log(`[Fleetbo] ⏳ Please wait for the green message...`);
|
|
762
762
|
console.log('[Fleetbo] ---------------------------------------------------');
|
|
763
763
|
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
const
|
|
775
|
-
|
|
776
|
-
if (
|
|
777
|
-
|
|
764
|
+
// ============================================
|
|
765
|
+
// UPLINK avec auto-retry (Fleetbo OS Resilience)
|
|
766
|
+
// ============================================
|
|
767
|
+
const MAX_UPLINK_RETRIES = 5;
|
|
768
|
+
const RETRY_DELAYS = [0, 10, 20, 30, 45];
|
|
769
|
+
let uplinkFound = false;
|
|
770
|
+
|
|
771
|
+
const startUplink = (attempt) => {
|
|
772
|
+
if (uplinkFound) return;
|
|
773
|
+
|
|
774
|
+
const npxCmd = process.platform === 'win32' ? 'npx.cmd' : 'npx';
|
|
775
|
+
|
|
776
|
+
if (attempt > 0) {
|
|
777
|
+
console.log(`\x1b[33m[Fleetbo] 🔄 Uplink reconnection ${attempt}/${MAX_UPLINK_RETRIES - 1}...\x1b[0m`);
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
uplinkProcess = spawn(npxCmd, [
|
|
781
|
+
'-y',
|
|
782
|
+
'cloudflared',
|
|
783
|
+
'tunnel',
|
|
784
|
+
'--url', `http://127.0.0.1:${PORT}`,
|
|
785
|
+
'--http-host-header', `127.0.0.1:${PORT}`
|
|
786
|
+
], { shell: true });
|
|
787
|
+
|
|
788
|
+
const handleUplinkOutput = (chunk) => {
|
|
789
|
+
const text = chunk.toString();
|
|
790
|
+
if (uplinkFound) return;
|
|
791
|
+
const match = text.match(/https:\/\/[a-zA-Z0-9-]+\.trycloudflare\.com/);
|
|
792
|
+
if (match) {
|
|
793
|
+
uplinkFound = true;
|
|
794
|
+
syncFirebase(process.env.REACT_KEY_APP, match[0], process.env.REACT_APP_TESTER_EMAIL);
|
|
795
|
+
}
|
|
796
|
+
};
|
|
797
|
+
|
|
798
|
+
// Écoute sur les deux flux (stdout + stderr)
|
|
799
|
+
uplinkProcess.stdout.on('data', handleUplinkOutput);
|
|
800
|
+
uplinkProcess.stderr.on('data', handleUplinkOutput);
|
|
801
|
+
|
|
802
|
+
uplinkProcess.on('error', (err) => {
|
|
803
|
+
if (uplinkFound) return;
|
|
804
|
+
console.error(`\x1b[31m[Fleetbo] ⚠️ Uplink Connection failed to establish.\x1b[0m`);
|
|
805
|
+
});
|
|
806
|
+
|
|
807
|
+
uplinkProcess.on('close', (code) => {
|
|
808
|
+
if (uplinkFound) return;
|
|
809
|
+
|
|
810
|
+
const nextAttempt = attempt + 1;
|
|
811
|
+
if (nextAttempt < MAX_UPLINK_RETRIES) {
|
|
812
|
+
const delay = RETRY_DELAYS[nextAttempt] || 30;
|
|
813
|
+
console.log(`\x1b[33m[Fleetbo] ⚠️ Uplink interrupted. Fleetbo OS retrying in ${delay}s... (${nextAttempt}/${MAX_UPLINK_RETRIES - 1})\x1b[0m`);
|
|
814
|
+
setTimeout(() => startUplink(nextAttempt), delay * 1000);
|
|
815
|
+
} else {
|
|
816
|
+
console.error(`\x1b[31m[Fleetbo] ❌ Secure Uplink could not be established.\x1b[0m`);
|
|
817
|
+
console.error(`\x1b[90m[Fleetbo] Fleetbo OS network is temporarily unavailable.\x1b[0m`);
|
|
818
|
+
console.error(`\x1b[90m[Fleetbo] Your dev server is still running on http://localhost:${PORT}\x1b[0m`);
|
|
819
|
+
console.error(`\x1b[90m[Fleetbo] Restart with "npm run fleetbo" when the network is back.\x1b[0m`);
|
|
820
|
+
}
|
|
821
|
+
});
|
|
822
|
+
};
|
|
823
|
+
|
|
824
|
+
startUplink(0);
|
|
778
825
|
}
|
|
779
826
|
});
|
|
780
827
|
}
|