const app = require('./app.js');
const http = require('http');
const PORT = process.env.PORT || 5000;
const verifyLicense = require('./config/licenceChecker.config.js');
const server = http.createServer(app);
const databaseConnection = require("./config/db.config.js");


require('./socket.js').intializeSocket(server);
const startServer = async () => {
  server.listen(PORT, () => {
    databaseConnection();
    console.log(`Server running on port ${PORT}`);
  });
}
startServer()

process.on('unhandledRejection', (err) => {
  console.error('Unhandled Rejection:', err);
  server.close(() => process.exit(1));
});

process.on('uncaughtException', (err) => {
  console.error('Uncaught Exception:', err);
  process.exit(1);
}); 