-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
59 lines (41 loc) · 1.17 KB
/
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
56
57
58
59
/**
* Index
*
*/
"use strict";
/**
* Definition
*
* global variable
* block variable
* constant
*
* check config file is exist
* check config file
*
**/
const path = require('path');
global.ENV = 'production';
global.APP_PATH = __dirname;
global.LIBS_PATH = path.join(APP_PATH, 'libs');
const fs = require('fs')
, colors = require('colors')
, language = require(path.join(LIBS_PATH, 'language.js')) // ~/libs/language.js
;
// check config file is exist
if (!fs.existsSync(path.join(APP_PATH, 'config.js'))) {
console.error(colors.red(language.global.not_found_config_file), colors.bold('config.js'), colors.bold('config.default.js'), colors.bold('config.js'));
process.exit();
}
const initialize = require(path.join(LIBS_PATH, 'initialize.js')) // ~/libs/initialize.js
, config = require(path.join(APP_PATH, 'config.js')) // ~/config.js
;
global.LANG = config.local.language === 'zh' ? 'zh' : 'en';
global.DEBUG = config.debug ? true : false;
// check config file
!initialize.checkConfig() ? process.exit() : 0;
/**
* Start
*
**/
require(path.join(LIBS_PATH, 'server.js'))();