#!/usr/bin/env node import { spawn } from 'child_process'; import path from 'path'; import { fileURLToPath } from 'url'; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); // Set production environment process.env.NODE_ENV = 'production'; // Load production environment file if it exists const envFile = path.join(__dirname, '.env.production'); console.log('šŸš€ Starting Gooneral Wheelchair Backend in Production Mode'); console.log('šŸ“ Environment:', process.env.NODE_ENV); console.log('🌐 Port:', process.env.PORT || 3001); // Start the server const server = spawn('node', ['server.js'], { cwd: __dirname, stdio: 'inherit', env: { ...process.env, NODE_ENV: 'production' } }); server.on('error', (err) => { console.error('āŒ Failed to start server:', err); process.exit(1); }); server.on('close', (code) => { console.log(`šŸ›‘ Server process exited with code ${code}`); process.exit(code); }); // Graceful shutdown process.on('SIGINT', () => { console.log('\nšŸ›‘ Received SIGINT, shutting down gracefully...'); server.kill('SIGINT'); }); process.on('SIGTERM', () => { console.log('\nšŸ›‘ Received SIGTERM, shutting down gracefully...'); server.kill('SIGTERM'); });