|
|
@ -268,6 +268,38 @@ export NODE_PATH=$(npm root --quiet -g) |
|
|
|
*/ |
|
|
|
try { |
|
|
|
var mongoserver = JSON.parse(fs.readFileSync('./hybrid/venus-stats/config.json', 'utf8')) |
|
|
|
|
|
|
|
try { |
|
|
|
var MongoClient = require('mongodb').MongoClient; |
|
|
|
var mongourl = `mongodb://${mongoserver.mongo_user}:${mongoserver.mongo_pass}@${mongoserver.mongo_ip}:${mongoserver.mongo_port}`; |
|
|
|
const OPTS = { |
|
|
|
useNewUrlParser: true, |
|
|
|
useUnifiedTopology: true |
|
|
|
}; |
|
|
|
|
|
|
|
MongoClient.connect(mongourl, OPTS, function(err, db) { |
|
|
|
if(err){ |
|
|
|
console.log(err); |
|
|
|
} else { |
|
|
|
var dbo = db.db(mongoserver.mongo_db); |
|
|
|
//var findcoll = `{"stackid":"${res.bootstrapstackid}"}`
|
|
|
|
//{EmployeeName : {$regex: "Gu" }}
|
|
|
|
var limit = 15 |
|
|
|
dbo.collection(mongoserver.mongo_coll).find({"stackid":res.bootstrapstackid},{sort:{_id:-1}}).limit(limit).toArray(function(err, result) { |
|
|
|
if(err){ |
|
|
|
console.log(err); |
|
|
|
} else { |
|
|
|
console.log(result); |
|
|
|
db.close(); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|
} catch (err) { |
|
|
|
console.error(err); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const myExec = ` |
|
|
|
docker exec -it swarmlabwg-${res.bootstrapstackid} /bin/bash -c "ip link set ${DEV_NAME} down; ip link del ${DEV_NAME}" |
|
|
|
sleep 1 |
|
|
@ -392,10 +424,8 @@ app.post('/hybrid_join_connect', (req, res, next) => { |
|
|
|
if(RES.action == "connect"){ |
|
|
|
|
|
|
|
fs.writeFileSync(`./hybrid/connect/${RES.bootstrapstackid}/swarmlabstatus`, 'wgstatusclient=on'); |
|
|
|
|
|
|
|
var showexecrm = `/bin/sh ./hybrid/connect/${RES.bootstrapstackid}/swarmlabwg` |
|
|
|
execSync(showexecrm); |
|
|
|
|
|
|
|
var showexec = `docker ps --format '{"ID":"{{ .ID }}", "Image": "{{ .Image }}", "Names":"{{ .Names }}", "Ports":"{{.Ports}}", "Networks":"{{.Networks}}", "Status":"{{.Status}}","RunningFor":"{{.RunningFor}}","CreatedAt":"{{.CreatedAt}}"}' | jq . -s ` |
|
|
|
exec(showexec, (err, stdout, stderr) => { |
|
|
|
if (err) { |
|
|
@ -419,7 +449,6 @@ app.post('/hybrid_join_connect', (req, res, next) => { |
|
|
|
} |
|
|
|
|
|
|
|
RES.debug = datajson |
|
|
|
|
|
|
|
if(results){ |
|
|
|
RES.error = false |
|
|
|
RES.error_msg = "ok" |
|
|
|