Commit 78a3124f authored by Ryan Kuba's avatar Ryan Kuba

#40 adding the spinup of all taisun containers found on the host to the start of Taisun

parent 0b5dbafe
Pipeline #15284303 canceled with stage
......@@ -49,6 +49,7 @@ guacontainer.inspect(function (err, containerdata) {
// For first time users or people that do not care about VDI
if (containerdata == null){
console.log('Guacd does not exist on this server will not start websocket tunnel');
startstacks();
}
else {
// Start Guacd if it exists and it not running then exit the process supervisor will pick it up
......@@ -63,6 +64,7 @@ guacontainer.inspect(function (err, containerdata) {
// If it is up and running use the IP we got from inspect to fire up the websocket tunnel used by the VDI application
else {
const guacServer = new GuacamoleLite({server: http,path:'/guaclite'},{host:containerdata.NetworkSettings.IPAddress,port:4822},clientOptions);
startstacks();
}
}
});
......@@ -79,6 +81,28 @@ const encrypt = (value) => {
return new Buffer(JSON.stringify(data)).toString('base64');
};
// Start all Taisun Stack containers
function startstacks(){
docker.listContainers({all: true}, function (err, containers) {
if (err){
console.log(err);
}
else{
containers.forEach(function(container){
// If the container has a stackname label assume it is a taisun container
if (container.Labels.stackname){
// If the container is not running
if (container.State != 'running'){
var contostart = docker.getContainer(container.Id);
contostart.start();
console.log('Started ' + container.Names[0] + ' time=' + (new Date).getTime());
}
}
});
}
});
}
////// PATHS //////
//// Main ////
app.get("/", function (req, res) {
......
......@@ -834,7 +834,8 @@ function updatelocalstacks(containers){
<thead>\
<tr>\
<th>Name</th>\
<th>URL</th>\
<th>App Launch</th>\
<th>Source</th>\
<th>Status</th>\
<th>Created</th>\
</tr>\
......@@ -887,6 +888,7 @@ function updatelocalstacks(containers){
stacktable.row.add(
[labels.stackname,
'<a href="http://' + host + ':' + labels.appport + '" target="_blank" class="btn btn-sm btn-primary">Launch</a>',
'<a href="' + labels.stackurl + '" target="_blank" class="btn btn-sm btn-primary">Source Template</a>',
container.State + ' ' + container.Status,
new Date( container.Created * 1e3).toISOString().slice(0,19)]
);
......
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