-
Notifications
You must be signed in to change notification settings - Fork 18
/
bin.js
78 lines (66 loc) · 2.38 KB
/
bin.js
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
process.title = 'YGOSalvation Server';
require('dotenv').config();
require('colors');
const
ADMIN_SERVER_URL = process.env.ADMIN_SERVER_URL,
child_process = require('child_process'),
server = require('./src'),
fs = require('fs'),
ADMIN_SERVER_USERNAME = process.env.ADMIN_SERVER_USERNAME,
ADMIN_SERVER_PASSWORD = process.env.ADMIN_SERVER_PASSWORD,
os = require('os');
let adminServer,
databaseServer,
srvpro,
proxyServer;
/**
* Program Entry Point
* @returns {undefined}
*/
function main() {
console.log('[SERVER] YGO Salvation Server - Saving Yu-Gi-Oh!'.bold.green);
const banlist = './http/manifest/banlist.json';
if (os.platform() === 'win32' && process.env.NODIST_X64 !== '0') {
console.error('Node is Running in 64bit mode, games can not start.');
console.info('HINT --> SET NODIST_X64=0'.bold.yellow);
if (!process.env.DEFIANT) {
process.exit(1);
}
}
if (!ADMIN_SERVER_URL || !ADMIN_SERVER_USERNAME || !ADMIN_SERVER_PASSWORD) {
console.error('Administrative Server and User are not configured, no database access.');
console.info('HINT --> README.MD'.bold.yellow);
if (!process.env.DEFIANT) {
process.exit(1);
}
}
if (Boolean(process.env.ADMIN_SERVER_LOCAL)) {
console.log('[SERVER] Starting Admin Server'.bold.green);
adminServer = child_process.fork('../ygosalvation-admin/src/server.js');
}
if (Boolean(process.env.DATABASE_SERVER_LOCAL)) {
console.log('[SERVER] Starting Database Server'.bold.green);
databaseServer = child_process.fork('../ygosalvation-database/app.js', [], {
});
}
if (Boolean(process.env.SRVPRO)) {
console.log('[SERVER] Starting Database Server'.bold.green);
srvpro = child_process.fork('../srvpro/', [], {
});
}
if (Boolean(process.env.PROXY_PORT)) {
console.log('[SERVER] Starting Network Proxy Server'.bold.green);
proxyServer = child_process.fork('./src/server_proxy.js', [], {
env: process.env
});
}
fs.access(banlist, function (err) {
if (err && err.code === 'ENOENT') {
console.error('Error: Banlist not generated, run "npm run banlist"');
console.info('HINT --> npm run banlist'.bold.yellow);
process.exit();
}
server();
});
}
main();