-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathide_index.js
55 lines (46 loc) · 1.52 KB
/
ide_index.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
const forever = require('forever-monitor');
const logjs = require('logjsx');
const fs = require('fs');
const path = require('path');
const logger = new logjs();
logger.init({
level: "DEBUG"
});
function App(config) {
let process = "rotor_ide";
let app_config = {
silent: false,
uid: process,
pidFile: "./" + process + ".pid",
max: 10,
killTree: true,
minUptime: 2000,
spinSleepTime: 1000,
args: [],
watch: false,
watchIgnoreDotFiles: null,
watchIgnorePatterns: null,
watchDirectory: null,
logFile: __dirname + "/" + config.log_dir + process + "/logFile.log",
outFile: __dirname + "/" + config.log_dir + process + "/outFile.log",
errFile: __dirname + "/" + config.log_dir + process + "/errFile.log"
};
this.start = async function(port) {
await this.createDir(config.log_dir + process + "/");
let app = forever.start(["ng", "serve", "--port", port + ""], app_config);
app.on('start', function (code) {
logger.info("Rotor IDE started (" + port + ")");
});
};
this.createDir = async function (dirPath) {
if (!await fs.existsSync(dirPath)) {
try {
await fs.mkdirSync(dirPath);
} catch (e) {
await this.createDir(path.dirname(dirPath));
await this.createDir(dirPath);
}
}
};
}
module.exports = App;