-
Notifications
You must be signed in to change notification settings - Fork 378
/
proactively_update_global_conf_in_redis.js
30 lines (25 loc) · 1.19 KB
/
proactively_update_global_conf_in_redis.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
const baseAbsPath = __dirname + '/';
const request = require('request');
const fs = require('fs');
const sioConfFilePath = baseAbsPath + './battle_srv/configs/sio.json';
const origSioConfJsonStr = fs.readFileSync(sioConfFilePath, "utf8");
const sioConfJsonObj = JSON.parse(origSioConfJsonStr);
const serverPort = sioConfJsonObj.port;
const globalConfFilePath = baseAbsPath + './battle_srv/configs/global_conf.json';
const origGlobalConfJsonStr = fs.readFileSync(globalConfFilePath, "utf8");
const globalConfJsonObj = JSON.parse(origGlobalConfJsonStr);
const reqFormObj = {};
for (let k in globalConfJsonObj) {
const candidate = globalConfJsonObj[k];
if (typeof candidate == 'number' || typeof candidate == 'string') {
reqFormObj[k] = candidate;
}
}
console.log("reqFormObj is ", reqFormObj);
request.post('http://localhost:' + serverPort + '/api/v1/Global/Conf/Modify', {
form: reqFormObj
}, function (error, response, body) {
console.log('error:', error); // Print the error if one occurred
console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
console.log('body:', body); // Print the HTML for the Google homepage.
});