electron-connect
electron-connect copied to clipboard
restart() closes the window, but never opens a new one
For me restart()
closes the window but never opens a new one. From what I see in the source, in order to respawn the process, logic should enter the if (!this.numClients) {...
conditional, but it never does, since numClients
is decremented only after the client closes websocket connection and for this to happen, probably process should be killed first.
ProcessManager.prototype.restart = function (args, cb) {
// ...
if (typeof cb === 'function') {
this.restartCallback = cb;
}
this.electronState = 'restarting';
if (this.electronProc) {
this.info('restarting electron process: ' + this.electronProc.pid);
if (!this.numClients) {
this.killProcess(function() {
this.info('respawning electron process..');
this.spawn(args, this.opt.spawnOpt);
this.setStateAndInvokeCallback('restarted', this.restartCallback);
}.bind(this));
} else {
this.killProcess(function() {
if (this.restartCallback) {
this.restartCallback(this.electronState);
}
}.bind(this));
}
}
};
electron-connect
server starts many electron processes (much more than one or two), I suppose that's just how underlying Chromium works?
But the real problem it seems is that after electron-connect
does killProcess
not all of those processes disappear. At least two are left:
If I kill them off manually then websocket gets finally closed and restart logic kicks in, respawning electron window.
Shouldn't killProcess
shutdown the whole tree of processes?