mirror of https://github.com/docker/docs.git
Added closing of event listener
Signed-off-by: French Ben <me+git@frenchben.com>
This commit is contained in:
parent
b8495ee800
commit
d0e490dd6e
|
|
@ -66,8 +66,14 @@ setupUtil.setup().then(() => {
|
||||||
throw err;
|
throw err;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
ipcRenderer.on('application:quitting', () => {
|
ipcRenderer.on('application:quitting', () => {
|
||||||
|
docker.detachEvent();
|
||||||
if (localStorage.getItem('settings.closeVMOnQuit') === 'true') {
|
if (localStorage.getItem('settings.closeVMOnQuit') === 'true') {
|
||||||
machine.stop();
|
machine.stop();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
window.onbeforeunload = function () {
|
||||||
|
docker.detachEvent();
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ app.on('ready', function () {
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
if (os.platform() === 'win32') {
|
if (os.platform() === 'win32') {
|
||||||
mainWindow.on('close', function () {
|
mainWindow.on('close', function () {
|
||||||
mainWindow.webContents.send('application:quitting');
|
mainWindow.webContents.send('application:quitting');
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,6 @@ var ContainerUtil = {
|
||||||
var [dockerPort, portType] = key.split('/');
|
var [dockerPort, portType] = key.split('/');
|
||||||
var localUrl = null;
|
var localUrl = null;
|
||||||
var port = null;
|
var port = null;
|
||||||
|
|
||||||
if (value && value.length) {
|
if (value && value.length) {
|
||||||
port = value[0].HostPort;
|
port = value[0].HostPort;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,8 @@ export default {
|
||||||
host: null,
|
host: null,
|
||||||
client: null,
|
client: null,
|
||||||
placeholders: {},
|
placeholders: {},
|
||||||
streams: {},
|
stream: null,
|
||||||
|
eventStream: null,
|
||||||
activeContainerName: null,
|
activeContainerName: null,
|
||||||
|
|
||||||
setup (ip, name) {
|
setup (ip, name) {
|
||||||
|
|
@ -377,7 +378,7 @@ export default {
|
||||||
},
|
},
|
||||||
|
|
||||||
active (name) {
|
active (name) {
|
||||||
this.detach();
|
this.detachLog();
|
||||||
this.activeContainerName = name;
|
this.activeContainerName = name;
|
||||||
|
|
||||||
if (name) {
|
if (name) {
|
||||||
|
|
@ -431,9 +432,7 @@ export default {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.stream) {
|
this.detachLog()
|
||||||
this.detach();
|
|
||||||
}
|
|
||||||
this.stream = logStream;
|
this.stream = logStream;
|
||||||
|
|
||||||
let timeout = null;
|
let timeout = null;
|
||||||
|
|
@ -452,14 +451,22 @@ export default {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
detach () {
|
detachLog() {
|
||||||
if (this.stream) {
|
if (this.stream) {
|
||||||
this.stream.destroy();
|
this.stream.destroy();
|
||||||
this.stream = null;
|
this.stream = null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
detachEvent() {
|
||||||
|
if (this.eventStream) {
|
||||||
|
this.eventStream.destroy();
|
||||||
|
this.eventStream = null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
listen () {
|
listen () {
|
||||||
|
this.detachEvent()
|
||||||
this.client.getEvents((error, stream) => {
|
this.client.getEvents((error, stream) => {
|
||||||
if (error || !stream) {
|
if (error || !stream) {
|
||||||
// TODO: Add app-wide error handler
|
// TODO: Add app-wide error handler
|
||||||
|
|
@ -474,13 +481,13 @@ export default {
|
||||||
|
|
||||||
if (data.status === 'destroy') {
|
if (data.status === 'destroy') {
|
||||||
containerServerActions.destroyed({id: data.id});
|
containerServerActions.destroyed({id: data.id});
|
||||||
this.detach(data.id);
|
this.detachLog()
|
||||||
} else if (data.status === 'kill') {
|
} else if (data.status === 'kill') {
|
||||||
containerServerActions.kill({id: data.id});
|
containerServerActions.kill({id: data.id});
|
||||||
this.detach(data.id);
|
this.detachLog()
|
||||||
} else if (data.status === 'stop') {
|
} else if (data.status === 'stop') {
|
||||||
containerServerActions.stopped({id: data.id});
|
containerServerActions.stopped({id: data.id});
|
||||||
this.detach(data.id);
|
this.detachLog()
|
||||||
} else if (data.status === 'create') {
|
} else if (data.status === 'create') {
|
||||||
this.logs();
|
this.logs();
|
||||||
this.fetchContainer(data.id);
|
this.fetchContainer(data.id);
|
||||||
|
|
@ -491,6 +498,7 @@ export default {
|
||||||
this.fetchContainer(data.id);
|
this.fetchContainer(data.id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
this.eventStream = stream;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue