electron-workers icon indicating copy to clipboard operation
electron-workers copied to clipboard

Kill doesn't work?

Open aredfox opened this issue 9 years ago • 0 comments

electronWorkers.kill(true); or electronWorkers.kill(); doesn't seem to work. My background process keeps running :/... The "quit" is called when the main process that spawns electronWorkers is being stopped... I also tried posting another command, but that doesn't seem to work either. Am I doing something wrong?

Example code:

let electronWorkers = require('electron-workers')({
    connectionMode: 'server',
    pathToScript: path.join(__dirname, 'lib', 'capture', 'screenshots', 'screenshots.worker.js'),
    timeout: 20000,
    numberOfWorkers: 1
});
function startCapture() {    
    electronWorkers.start(function(startErr) {
        if (startErr) { /*throw new Error(startErr); */}
 
    // `electronWorkers` will send your data in a POST request to your electron script 
        electronWorkers.execute(
            { cmd: 'start', capturePath: global.config.app('capture.screenshots'), isVisible: global.config.isDev() }, 
            (err, data) => { }
        );
    });
}
function quit(message) {    
    electronWorkers.execute({ cmd: 'quit' }, (err, data) => { });
    electronWorkers.kill(true);
    if(app && app !== undefined) {
        if(message) {
            console.log(`~~ APP: Quitting: "${message}".`);
        } else {
            console.log(`~~ APP: Quitting.`);
        }
        app.quit();        
    }
}

aredfox avatar Dec 08 '16 21:12 aredfox