Registration and activation
This commit is contained in:
@@ -2,8 +2,7 @@ import http from 'http';
|
||||
import { Server } from 'socket.io';
|
||||
import amqp from 'amqplib/callback_api.js';
|
||||
import app from './app.js';
|
||||
import path from 'path';
|
||||
import express from 'express';
|
||||
import { syncDatabase } from './utils/syncDatabase.js';
|
||||
|
||||
const server = http.createServer(app);
|
||||
const io = new Server(server);
|
||||
@@ -11,14 +10,6 @@ const io = new Server(server);
|
||||
const RABBITMQ_URL = 'amqp://localhost';
|
||||
const QUEUE = 'chat_messages';
|
||||
|
||||
const __dirname = path.resolve();
|
||||
const frontendPath = path.join(__dirname, 'path/to/your/frontend/build/folder');
|
||||
app.use(express.static(frontendPath));
|
||||
|
||||
app.get('*', (req, res) => {
|
||||
res.sendFile(path.join(frontendPath, 'index.html'));
|
||||
});
|
||||
|
||||
amqp.connect(RABBITMQ_URL, (err, connection) => {
|
||||
if (err) {
|
||||
throw err;
|
||||
@@ -48,8 +39,14 @@ amqp.connect(RABBITMQ_URL, (err, connection) => {
|
||||
});
|
||||
});
|
||||
|
||||
server.listen(3001, () => {
|
||||
console.log('Server is running on port 3001');
|
||||
// Sync database before starting the server
|
||||
syncDatabase().then(() => {
|
||||
server.listen(3001, () => {
|
||||
console.log('Server is running on port 3001');
|
||||
});
|
||||
}).catch(err => {
|
||||
console.error('Failed to sync database:', err);
|
||||
process.exit(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user