|
|
@ -5,14 +5,34 @@ import { startServer } from './server/server';
|
|
|
|
// Load environment variables
|
|
|
|
// Load environment variables
|
|
|
|
dotenv.config();
|
|
|
|
dotenv.config();
|
|
|
|
|
|
|
|
|
|
|
|
const PORT = 3000;
|
|
|
|
// Get port from environment or default to 3000
|
|
|
|
|
|
|
|
const PORT = process.env.PORT ? parseInt(process.env.PORT) : 3000;
|
|
|
|
|
|
|
|
|
|
|
|
// Start the bot and server
|
|
|
|
// Start the bot and server
|
|
|
|
async function main() {
|
|
|
|
async function main() {
|
|
|
|
await startBot();
|
|
|
|
try {
|
|
|
|
startServer(PORT);
|
|
|
|
console.log('Starting bot...');
|
|
|
|
|
|
|
|
await startBot();
|
|
|
|
|
|
|
|
console.log('Bot started successfully');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
console.log('Starting server...');
|
|
|
|
|
|
|
|
startServer(PORT);
|
|
|
|
|
|
|
|
console.log(`Server running on port ${PORT}`);
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
|
|
console.error('Error starting application:', error);
|
|
|
|
|
|
|
|
process.exit(1);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
main().catch((error) => {
|
|
|
|
// Handle process termination
|
|
|
|
console.error('Error starting the bot:', error);
|
|
|
|
process.on('SIGINT', () => {
|
|
|
|
|
|
|
|
console.log('Shutting down gracefully...');
|
|
|
|
|
|
|
|
process.exit(0);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
process.on('SIGTERM', () => {
|
|
|
|
|
|
|
|
console.log('Shutting down gracefully...');
|
|
|
|
|
|
|
|
process.exit(0);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
main();
|
|
|
|