Browse Source
Prevent zombie processes in dev mode when refreshing app
master
meriadec
7 years ago
No known key found for this signature in database
GPG Key ID: 1D2FC2305E2CB399
2 changed files with
13 additions and
0 deletions
-
src/main/bridge.js
-
src/renderer/events.js
|
|
@ -7,6 +7,12 @@ import { resolve } from 'path' |
|
|
|
|
|
|
|
import setupAutoUpdater, { quitAndInstall } from './autoUpdate' |
|
|
|
|
|
|
|
const processes = [] |
|
|
|
|
|
|
|
function cleanProcesses() { |
|
|
|
processes.forEach(kill => kill()) |
|
|
|
} |
|
|
|
|
|
|
|
function onForkChannel(forkType, callType) { |
|
|
|
return (event: any, payload) => { |
|
|
|
const { type, data } = payload |
|
|
@ -24,6 +30,8 @@ function onForkChannel(forkType, callType) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
processes.push(kill) |
|
|
|
|
|
|
|
const onMessage = payload => { |
|
|
|
const { type, data, options = {} } = payload |
|
|
|
if (callType === 'async') { |
|
|
@ -48,6 +56,8 @@ function onForkChannel(forkType, callType) { |
|
|
|
ipcMain.on('usb', onForkChannel('usb', 'async')) |
|
|
|
ipcMain.on('accounts', onForkChannel('accounts', 'async')) |
|
|
|
|
|
|
|
ipcMain.on('clean-processes', cleanProcesses) |
|
|
|
|
|
|
|
const handlers = { |
|
|
|
updater: { |
|
|
|
init: setupAutoUpdater, |
|
|
|
|
|
@ -120,6 +120,9 @@ export default ({ store, locked }: { store: Object, locked: boolean }) => { |
|
|
|
handler(data) |
|
|
|
}) |
|
|
|
|
|
|
|
// Ensure all sub-processes are killed before creating new ones (dev mode...)
|
|
|
|
ipcRenderer.send('clean-processes') |
|
|
|
|
|
|
|
// Start detection when we plug/unplug devices
|
|
|
|
sendEvent('usb', 'devices.listen') |
|
|
|
|
|
|
|