|
|
@ -194,14 +194,16 @@ docker run -d \ |
|
|
|
-v ${mypath}/hybrid/connect:/settingsclient \ |
|
|
|
-v /lib/modules:/lib/modules \ |
|
|
|
--restart unless-stopped \ |
|
|
|
hub.swarmlab.io:5480/venusclient:latest |
|
|
|
hub.swarmlab.io:5480/venusclient:latest /bin/bash -c "pm2-runtime start /app/swarmlab-venus/client_ecosystem.config.js" |
|
|
|
` |
|
|
|
fs.writeFileSync('./hybrid/connect/swarmlabwg', myExec); |
|
|
|
fs.writeFileSync('./hybrid/connect/swarmlabstatus', 'wgstatusclient=off'); |
|
|
|
|
|
|
|
const myExec1 = ` |
|
|
|
docker stop swarmlabwg; docker container rm swarmlabwg |
|
|
|
sleep 1 |
|
|
|
docker exec -it swarmlabwg /bin/bash -c "ip link set swarmlab0 down; ip link del swarmlab0" |
|
|
|
sleep 1 |
|
|
|
docker stop swarmlabwg; docker container rm swarmlabwg |
|
|
|
sleep 1 |
|
|
|
` |
|
|
|
fs.writeFileSync('./hybrid/connect/swarmlabwgdown', myExec1); |
|
|
|
|
|
|
@ -366,6 +368,52 @@ app.post('/hybrid_join_connect', (req, res, next) => { |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app.get('/getserviceshybridstatus', (req, res, next) => { |
|
|
|
|
|
|
|
var RES = new Object(); |
|
|
|
RES.bootstrapnameid = req.query["bootstrapnameid"] |
|
|
|
// swarmlab name swarmlabwg
|
|
|
|
RES.bootstrapstackname = req.query["bootstrapstackname"] |
|
|
|
var showexec = `docker ps --format '{"Names":"{{ .Names }}", "Status":"{{.Status}}"}' | jq . -s ` |
|
|
|
exec(showexec, (err, stdout, stderr) => { |
|
|
|
if (err) { |
|
|
|
console.error(`exec error: ${err}`); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (stdout) { |
|
|
|
var string = stdout.toString() |
|
|
|
var datajson = JSON.parse(string); |
|
|
|
var search = RES.bootstrapstackname |
|
|
|
var extenderror = new RegExp(search); |
|
|
|
var found = 'no'; |
|
|
|
for(var i = 0; i < datajson.length; i++) { |
|
|
|
var servicename = datajson[i].Names |
|
|
|
//console.log(JSON.stringify(search+' '+servicename))
|
|
|
|
if(extenderror.test(servicename)){ |
|
|
|
found = 'yes'; |
|
|
|
} |
|
|
|
} |
|
|
|
RES.error = false |
|
|
|
RES.error_msg = "ok" |
|
|
|
RES.test = datajson; |
|
|
|
RES.data = found; |
|
|
|
res.json(RES) |
|
|
|
|
|
|
|
}else{ |
|
|
|
var found = 'no' |
|
|
|
RES.error = false |
|
|
|
RES.error_msg = "ok" |
|
|
|
RES.data = found; |
|
|
|
res.json(RES) |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
server.listen(serverPort, function() { |
|
|
|
console.log('server up and running at %s port', serverPort); |
|
|
|
}); |
|
|
|