Commit 56158abf by 王栋源

wdy

parent e652d043
var childproc = require('child_process'); var childproc = require('child_process');
const util = require('util'); const util = require('util');
const exec = util.promisify(require('child_process').exec); const exec = util.promisify(require('child_process').exec);
const uuidv4 = require('uuid/v4');
class ExecClient { class ExecClient {
constructor() { constructor() {
this.cmdPostPattern = "curl --user admines:adminGSBes. -k -H 'Content-type: application/json' -d '{data}' {url}"; this.cmdPostPattern = "curl --user admines:adminGSBes. -k -H 'Content-type: application/json' -d '{data}' {url}";
this.cmdGetPattern = "curl -G -X GET '{url}'"; this.cmdGetPattern = "curl -G -X GET '{url}'";
this.cmdPushDataPostPattern = "curl -k -H 'Content-type: application/json' -H 'token:{tk}' -H 'request-id:{requestId}' -d '{data}' {url}";
} }
async exec(cmd) { async exec(cmd) {
...@@ -69,6 +71,26 @@ class ExecClient { ...@@ -69,6 +71,26 @@ class ExecClient {
const {stdout, stderr} = await exec(cmd, options); const {stdout, stderr} = await exec(cmd, options);
return {stdout, stderr}; return {stdout, stderr};
} }
getUUID() {
var uuid = uuidv4();
var u = uuid.replace(/\-/g, "");
return u;
}
FetchPushDataPostCmd(subData, url, token, requestId) {
var requestId = requestId || this.getUUID();
var data = JSON.stringify(subData);
var cmd = this.cmdPushDataPostPattern.replace(/\{data\}/g,
data).replace(/\{url\}/g, url).replace(/\{tk\}/g, token).replace(/\{requestId\}/g, requestId);
console.log(cmd);
return cmd;
}
async execPushDataPost(subData, url, token, requestId) {
let cmd = this.FetchPushDataPostCmd(subData, url, token, requestId);
var result = await this.exec(cmd);
return result;
}
} }
module.exports = ExecClient; module.exports = ExecClient;
......
...@@ -7,11 +7,11 @@ var settings={ ...@@ -7,11 +7,11 @@ var settings={
}, },
database:{ database:{
dbname : "zc", dbname : "zc",
user: "root", user: "write",
password: "123456", password: "write",
config: { config: {
host: '192.168.4.119', host: '43.247.184.35',
port: 3306, port: 8899,
dialect: 'mysql', dialect: 'mysql',
operatorsAliases: false, operatorsAliases: false,
pool: { pool: {
......
...@@ -38,6 +38,13 @@ var settings = { ...@@ -38,6 +38,13 @@ var settings = {
return "http://43.247.184.94:7200/"; return "http://43.247.184.94:7200/";
} }
}, },
centerChannelUrl: function () {
if (this.env == "dev") {
return "http://gsb.qifu.gongsibao.com:4012/";
} else {
return "http://center-channel-service/";
}
},
reqEsAddrIc:function(){ reqEsAddrIc:function(){
if(this.env=="dev"){ if(this.env=="dev"){
var localsettings=require("./localsettings"); var localsettings=require("./localsettings");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment