-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
38 lines (24 loc) · 805 Bytes
/
server.js
File metadata and controls
38 lines (24 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import {exec} from 'child_process';
import dotenv from 'dotenv';
dotenv.config();
const getPort = () => {
const envPort = process.env.PORT || '3000';
const port = parseInt(envPort, 10);
if (isNaN(port) || port < 0 || port >= 65536) {
console.error(`Invalid port number: ${envPort}. Using default port 3000.`);
return 3000;
}
return port;
};
process.env.PORT = getPort().toString();
console.log(`⚡️ Starting DeBot Next.js server on port ${process.env.PORT}...`);
exec('next start', (error, stdout, stderr) => {
if (error) {
console.error(`Error starting Next.js server: ${error.message}`);
return process.exit(1);
}
if (stderr) {
console.error(`Next.js server stderr: ${stderr}`);
}
console.log(stdout);
});