mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-29 02:30:28 +00:00
refactor(cloudcmd) readConfig: mv to bin
This commit is contained in:
parent
882252432d
commit
985c900b05
2 changed files with 44 additions and 32 deletions
40
cloudcmd.js
40
cloudcmd.js
|
|
@ -9,7 +9,6 @@
|
|||
mellow = require(DIR_SERVER + 'mellow'),
|
||||
|
||||
HTMLDIR = main.HTMLDIR,
|
||||
JSONDIR = main.JSONDIR,
|
||||
|
||||
fs = main.fs,
|
||||
files = main.files,
|
||||
|
|
@ -25,8 +24,6 @@
|
|||
|
||||
win = require(DIR_SERVER + 'win'),
|
||||
|
||||
CONFIG_PATH = JSONDIR + 'config.json',
|
||||
|
||||
KEY = DIR + 'ssl/ssl.key',
|
||||
CERT = DIR + 'ssl/ssl.crt',
|
||||
|
||||
|
|
@ -48,10 +45,8 @@
|
|||
/* reinit main dir os if we on Win32 should be backslashes */
|
||||
DIR = main.DIR;
|
||||
|
||||
exports.start = function(params) {
|
||||
readConfig(function() {
|
||||
init(params);
|
||||
});
|
||||
exports.start = function(config) {
|
||||
init(config);
|
||||
|
||||
win.prepareCodePage();
|
||||
};
|
||||
|
|
@ -117,7 +112,7 @@
|
|||
}
|
||||
|
||||
|
||||
function init(params) {
|
||||
function init(config) {
|
||||
var paramsStart;
|
||||
|
||||
Util.log('server dir: ' + DIR);
|
||||
|
|
@ -125,8 +120,12 @@
|
|||
if (update)
|
||||
update.get();
|
||||
|
||||
if (params && params.test)
|
||||
Config.server = false;
|
||||
if (config) {
|
||||
main.config = Config = config;
|
||||
|
||||
if (config.test)
|
||||
Config.server = false;
|
||||
}
|
||||
|
||||
if (Config.logs) {
|
||||
Util.log('log param setted up in config.json\n' +
|
||||
|
|
@ -192,27 +191,6 @@
|
|||
});
|
||||
}
|
||||
|
||||
function readConfig(callback) {
|
||||
Util.checkArgs(arguments, ['callback']);
|
||||
|
||||
fs.readFile(CONFIG_PATH, 'utf8', function(error, data) {
|
||||
var status, json, msg;
|
||||
|
||||
if (error)
|
||||
status = 'error';
|
||||
else {
|
||||
status = 'ok';
|
||||
json = Util.parseJSON(data);
|
||||
main.config = Config = json;
|
||||
}
|
||||
|
||||
msg = CloudFunc.formatMsg('read', 'config', status);
|
||||
|
||||
Util.log(msg);
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* routing of server queries
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue