blob: 54d7638dcd987d09c497c0ed4dc74be4af5845d5 (
plain)
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
|
if (require('os').platform() === "win32") {
console.log("Electrode cannot run on Windows. Please use a POSIX-compliant operating system to run an Electrode server.");
process.exit(255);
}
const fs = require('fs');
const chalk = require('chalk');
const progress = require('progress');
global.cluster = require('cluster');
global.publicDir = __dirname + "/public";
if (require('fs').existsSync("./cache/download.tar")) {
require('fs').unlinkSync("./cache/download.tar");
}
if (require('fs').existsSync("./download")) {
require('fs').rmdirSync("./download", {
recursive: true
});
}
global.__CLUSTER_CPUSCOUNT = require('os').cpus().length;
global.__SYSTEMROOT = __dirname;
global.__RUNNING = false;
global.__SRUNNING = false;
if (cluster.isMaster) {
if (fs.existsSync("./public/cms-special")) {
setTimeout(() => {
console.log(chalk.blue("info: ") + "updating...");
p = require('child_process').spawnSync("./shared/updates.sh", [], {
stdio: 'inherit'
});
console.log(chalk.blue("info: ") + "finished");
if (p.status != 0) {
console.log(chalk.yellow("warn: ") + "update failed with exit code " + p.status);
}
require('./shared/bootstrap.js');
global.__SRUNNING = true;
}, 1250)
} else {
setTimeout(() => {
console.log(chalk.blue("info: ") + "downloading Neutron...");
p = require('child_process').spawnSync("./shared/updates.sh", [], {
stdio: 'inherit'
});
console.log(chalk.blue("info: ") + "finished");
if (p.status != 0) {
console.log(chalk.red("error: ") + "failed to download core with exit code " + p.status);
}
fs.copyFileSync("./php/headers.php", "./cache/headers.php");
require('./shared/bootstrap.js');
global.__SRUNNING = true;
}, 1250)
}
setInterval(() => {
if (__RUNNING) {
console.log(chalk.blue("info: ") + "updating...");
p = require('child_process').spawnSync("./shared/updates.sh", [], {
stdio: 'inherit'
});
console.log(chalk.blue("info: ") + "finished");
if (p.status != 0) {
console.log(chalk.yellow("warn: ") + "update failed with exit code " + p.status);
}
}
}, require('./config/updates.json').interval);
} else {
console.log(chalk.blue("info: ") + `worker #${cluster.worker.id} with pid ${process.pid} started`);
require('./runtime.js');
}
|