- Added tunnel
- Removed cloud feature
This commit is contained in:
decolua
2026-02-21 16:42:46 +07:00
parent adf57aa0c9
commit 0baa299722
37 changed files with 858 additions and 933 deletions

View File

@@ -362,6 +362,7 @@ export default function UsageStats() {
providers={providers}
activeRequests={stats.activeRequests || []}
lastProvider={stats.recentRequests?.[0]?.provider || ""}
errorProvider={stats.errorProvider || ""}
/>
<RecentRequests requests={stats.recentRequests || []} />
</div>

View File

@@ -0,0 +1,42 @@
import { cleanupProviderConnections, getSettings } from "@/lib/localDb";
import { enableTunnel } from "@/lib/tunnel/tunnelManager";
import { killCloudflared, isCloudflaredRunning, ensureCloudflared } from "@/lib/tunnel/cloudflared";
/**
* Initialize app on startup
* - Cleanup stale data
* - Auto-reconnect tunnel if previously enabled
* - Register shutdown handler to kill cloudflared
*/
export async function initializeApp() {
try {
await cleanupProviderConnections();
// Auto-reconnect tunnel if it was enabled before restart
const settings = await getSettings();
if (settings.tunnelEnabled && !isCloudflaredRunning()) {
console.log("[InitApp] Tunnel was enabled, auto-reconnecting...");
try {
await enableTunnel();
console.log("[InitApp] Tunnel reconnected");
} catch (error) {
console.log("[InitApp] Tunnel reconnect failed:", error.message);
}
}
// Kill cloudflared on process exit
const cleanup = () => {
killCloudflared();
process.exit();
};
process.on("SIGINT", cleanup);
process.on("SIGTERM", cleanup);
// Pre-download cloudflared binary in background
ensureCloudflared().catch(() => {});
} catch (error) {
console.error("[InitApp] Error:", error);
}
}
export default initializeApp;

View File

@@ -1,5 +1,7 @@
/* ========== CLOUD SYNC — COMMENTED OUT (replaced by Tunnel) ==========
import { getCloudSyncScheduler } from "@/shared/services/cloudSyncScheduler";
import { isCloudEnabled, cleanupProviderConnections } from "@/lib/localDb";
========== END CLOUD SYNC ========== */
import { cleanupProviderConnections } from "@/lib/localDb";
/**
* Initialize cloud sync scheduler
@@ -10,6 +12,7 @@ export async function initializeCloudSync() {
// Cleanup null fields from existing data
await cleanupProviderConnections();
/* ========== CLOUD SYNC — COMMENTED OUT (replaced by Tunnel) ==========
// Create scheduler instance with default 15-minute interval
const scheduler = await getCloudSyncScheduler(null, 15);
@@ -17,6 +20,8 @@ export async function initializeCloudSync() {
await scheduler.start();
return scheduler;
========== END CLOUD SYNC ========== */
return null;
} catch (error) {
console.error("[CloudSync] Error initializing scheduler:", error);
throw error;