Browse Source

Prevent zombie processes in dev mode when refreshing app

master
meriadec 7 years ago
parent
commit
92b5afa148
No known key found for this signature in database GPG Key ID: 1D2FC2305E2CB399
  1. 10
      src/main/bridge.js
  2. 3
      src/renderer/events.js

10
src/main/bridge.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,

3
src/renderer/events.js

@ -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')

Loading…
Cancel
Save