Created the app.js

This commit is contained in:
Mathias Wagner 2022-06-26 17:15:25 +02:00
parent 5474ce5766
commit 05aa7df7e2
Signed by: Mathias
GPG Key ID: B8DC354B0A1F5B44

22
app.js
View File

@ -0,0 +1,22 @@
const mongoose = require('mongoose');
const socketServer = require('./server/socket');
const expressServer = require('./server/api');
const downloadServer = require('./server/download');
const mediaServer = require('./server/media');
require('dotenv').config();
// Connect to the database
mongoose.connect(process.env.MONGOOSE_STRING, (e) => {
if (!e) {
console.log("Successfully connected to the database");
start();
} else console.error("Could not connect to the database: " + e.toString());
});
// Starts all servers
const start = () => {
expressServer.startServer(process.env.EXPRESS_PORT || 8352);
socketServer.startServer(process.env.SOCKET_PORT || 8353);
mediaServer.startServer(process.env.MEIDA_PORT || 8354);
downloadServer.startServer(process.env.DOWNLOAD_PORT || 8355, process.env.RELEASE_PATH || "/mnt/data/download");
}