Browse Source

add venus start

master
zeus 4 years ago
parent
commit
f17e25c7c4
  1. 19
      files/mongo/venus-stats.js
  2. 12
      llo/connect-new.js

19
files/mongo/venus-stats.js

@ -22,6 +22,14 @@ function getArgs () {
} }
const args = getArgs(); const args = getArgs();
function mysearch(nameKey, myArray){
for (var i=0; i < myArray.length; i++) {
if (myArray[i].name === nameKey) {
return myArray[i];
}
}
}
const { spawn, exec, execSync } = require('child_process') const { spawn, exec, execSync } = require('child_process')
//console.log(args) //console.log(args)
@ -39,6 +47,10 @@ if (args["insert"] == 'yes'){
var dbNamePort = args["port"] var dbNamePort = args["port"]
var dbNameIP = args["ip"] var dbNameIP = args["ip"]
var dbdate = args["json"] var dbdate = args["json"]
var stackid = args["stackid"]
var stackinterface = args["stackinterface"]
var stackpeer = args["stackpeer"]
var devname = args["devname"]
var showexec ='/usr/local/bin/wg-json'; var showexec ='/usr/local/bin/wg-json';
try { try {
@ -47,7 +59,8 @@ if (args["insert"] == 'yes'){
NODE_ENV: "production", NODE_ENV: "production",
}, },
}); });
var datajson = stdout.toString() var datajsontmp = stdout.toString()
var datajson = mysearch(devname, datajsontmp);
console.error('exec ' + JSON.stringify(datajson)); console.error('exec ' + JSON.stringify(datajson));
} catch (error) { } catch (error) {
var datajson = error.toString() var datajson = error.toString()
@ -57,6 +70,10 @@ if (args["insert"] == 'yes'){
var RESlog = new Object(); var RESlog = new Object();
RESlog.date = dbdate RESlog.date = dbdate
RESlog.log = datajson RESlog.log = datajson
RESlog.stackid = stackid
RESlog.stackinterface = stackinterface
RESlog.stackpeer = stackpeer
RESlog.devname = devname
var MongoClient = require('mongodb').MongoClient; var MongoClient = require('mongodb').MongoClient;

12
llo/connect-new.js

@ -305,11 +305,15 @@ docker run -d \
fs.writeFileSync(`./hybrid/connect/${res.bootstrapstackid}/swarmlabwg`, myExec); fs.writeFileSync(`./hybrid/connect/${res.bootstrapstackid}/swarmlabwg`, myExec);
fs.writeFileSync(`./hybrid/connect/${res.bootstrapstackid}/swarmlabstatus`, 'wgstatusclient=off'); fs.writeFileSync(`./hybrid/connect/${res.bootstrapstackid}/swarmlabstatus`, 'wgstatusclient=off');
const myExecLog = ` //stackid=2WpY5xabCndTNCvqYflUcORKTRDkf6e9
#!/bin/sh //stackinterface=YBqJjwhL6a9OOcWBUdC9PjM8Gr7AOzuNX5g1247mVl8=
//stackname=swarmlabwg-2WpY5xabCndTNCvqYflUcORKTRDkf6e9
//stackpeer=pl8Gf6HDMbKBHA/pQRPgCE7cdafoXVqpPo97I/tqlEQ=
date=`date '+%Y-%m-%d-%H:%M'` const myExecLog = `#!/bin/sh
node /usr/local/bin/venus-stats.js --insert=yes --port=${mongoserver.mongo_port} --ip='127.0.0.1' --user=swarmlab --password=${mongoserver.mongo_pass} --db=${mongoserver.mongo_db} --coll=${mongoserver.mongo_coll} --json=$date
date=\`date '+%Y-%m-%d-%H:%M'\`
node /usr/local/bin/venus-stats.js --insert=yes --port=${mongoserver.mongo_port} --ip='127.0.0.1' --user=swarmlab --password=${mongoserver.mongo_pass} --db=${mongoserver.mongo_db} --coll=${mongoserver.mongo_coll} --json=$date --stackid=${res.bootstrapstackid} --stackinterface=${res.privatekey} --stackpeer=${res.publickey} --devname=${DEV_NAME}
` `
fs.writeFileSync(`./hybrid/connect/${res.bootstrapstackid}/scripts/1/logs`, myExecLog); fs.writeFileSync(`./hybrid/connect/${res.bootstrapstackid}/scripts/1/logs`, myExecLog);

Loading…
Cancel
Save