LH-252: Update .env variables

This commit is contained in:
Sergiu Toma 2022-10-06 15:21:54 +03:00
parent 2aea7497cc
commit 5c2808e75a
2 changed files with 14 additions and 10 deletions

4
.env
View File

@ -1,3 +1,7 @@
PORT=3000
IP=0.0.0.0 # Listening IPv4 or IPv6.
ANNOUNCED_IP=185.8.154.190 # Announced IPv4 or IPv6 (useful when running mediasoup behind NAT with private IP).
RTC_MIN_PORT=2000
RTC_MAX_PORT=2020
SERVER_CERT="./server/ssl/cert.pem"
SERVER_KEY="./server/ssl/key.pem"

20
app.js
View File

@ -5,7 +5,7 @@ const app = express();
const Server = require('socket.io');
const path = require('node:path');
const fs = require('node:fs');
let https = require('https');
let https;
try {
https = require('node:https');
} catch (err) {
@ -42,8 +42,8 @@ app.use('/sfu', express.static(path.join(__dirname, 'public')))
// SSL cert for HTTPS access
const options = {
key: fs.readFileSync('./server/ssl/key.pem', 'utf-8'),
cert: fs.readFileSync('./server/ssl/cert.pem', 'utf-8'),
key: fs.readFileSync(process.env.SERVER_KEY, 'utf-8'),
cert: fs.readFileSync(process.env.SERVER_CERT, 'utf-8'),
}
const httpsServer = https.createServer(options, app);
@ -59,16 +59,16 @@ const io = new Server(httpsServer, {
// const io = new Server(server, { origins: '*:*', allowEIO3: true });
httpsServer.listen(process.env.PORT, () => {
console.log('Video server listening on port:', process.env.PORT)
})
console.log('Video server listening on port:', process.env.PORT);
});
const peers = io.of('/')
const peers = io.of('/');
const createWorker = async () => {
try {
worker = await mediasoup.createWorker({
rtcMinPort: 2000,
rtcMaxPort: 2020,
rtcMinPort: process.env.RTC_MIN_PORT,
rtcMaxPort: process.env.RTC_MAX_PORT,
})
console.log(`[createWorker] worker pid ${worker.pid}`);
@ -84,7 +84,7 @@ const createWorker = async () => {
}
// We create a Worker as soon as our application starts
worker = createWorker()
worker = createWorker();
// This is an Array of RtpCapabilities
// https://mediasoup.org/documentation/v3/mediasoup/rtp-parameters-and-capabilities/#RtpCodecCapability
@ -105,7 +105,7 @@ const mediaCodecs = [
'x-google-start-bitrate': 1000,
},
},
]
];
const closeCall = (callId) => {
try {