-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
36 lines (32 loc) · 995 Bytes
/
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
import appProcess from './src/app';
import Daemon from "./src/daemon";
import initDir from './src/tasks/initDir';
import logger, { initLog } from './src/logger';
import { userName, autoUpdate } from './src/config';
const ARGV_USER_NAME = process.argv[2] || '';
let daemon;
try {
(async () => {
let userSession;
if (userName) {
userSession = `${userName}_${Date.now()}`;
} else if (ARGV_USER_NAME) {
userSession = `${ARGV_USER_NAME}_${Date.now()}`;
} else {
userSession = `noname_${Date.now()}`;
}
await initDir(userSession);
initLog(userSession);
if (autoUpdate.enabled) {
daemon = new Daemon(userSession);
} else {
await appProcess(userSession);
}
})().catch((e) => {
logger.error(e.stack);
return Promise.reject(e);
});
} catch(e) {
console.error(`Application can't start correct: ${e.stack}`);
process.exit(1);
}