mirror of
https://github.com/ManInDark/HabitTrove.git
synced 2026-01-20 22:24:28 +01:00
Added auto-backups feature (#107)
This commit is contained in:
@@ -1,7 +1,28 @@
|
||||
import { init } from '@/lib/env.server' // startup env var check
|
||||
import { init } from '@/lib/env.server'; // startup env var check
|
||||
|
||||
export function register() {
|
||||
if (typeof window === "undefined") {
|
||||
init()
|
||||
}
|
||||
}
|
||||
// Ensure this function is exported
|
||||
export async function register() {
|
||||
// We only want to run this code on the server side
|
||||
if (process.env.NEXT_RUNTIME === 'nodejs') {
|
||||
console.log('Node.js runtime detected, running server-side instrumentation...');
|
||||
// Initialize environment variables first
|
||||
console.log('Initializing environment variables...');
|
||||
init();
|
||||
console.log('Environment variables initialized.');
|
||||
|
||||
// Dynamically import the scheduler initializer
|
||||
// Use await import() for ESM compatibility
|
||||
try {
|
||||
console.log('Attempting to import scheduler...');
|
||||
// Ensure the path is correct relative to the project root
|
||||
const { initializeScheduler } = await import('./lib/scheduler');
|
||||
console.log('Scheduler imported successfully. Initializing...');
|
||||
initializeScheduler();
|
||||
console.log('Scheduler initialization called.');
|
||||
} catch (error) {
|
||||
console.error('Failed to import or initialize scheduler:', error);
|
||||
}
|
||||
} else {
|
||||
console.log(`Instrumentation hook running in environment: ${process.env.NEXT_RUNTIME}. Skipping server-side initialization.`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user