|
@ -7,6 +7,8 @@ import { ipcMain, app } from 'electron' |
|
|
import { ipcMainListenReceiveCommands } from 'helpers/ipc' |
|
|
import { ipcMainListenReceiveCommands } from 'helpers/ipc' |
|
|
import path from 'path' |
|
|
import path from 'path' |
|
|
import logger from 'logger' |
|
|
import logger from 'logger' |
|
|
|
|
|
import sentry from 'sentry/node' |
|
|
|
|
|
import user from 'helpers/user' |
|
|
|
|
|
|
|
|
import setupAutoUpdater, { quitAndInstall } from './autoUpdate' |
|
|
import setupAutoUpdater, { quitAndInstall } from './autoUpdate' |
|
|
|
|
|
|
|
@ -17,6 +19,11 @@ const LEDGER_LIVE_SQLITE_PATH = path.resolve(app.getPath('userData'), 'sqlite') |
|
|
|
|
|
|
|
|
let internalProcess |
|
|
let internalProcess |
|
|
|
|
|
|
|
|
|
|
|
let sentryEnabled = false |
|
|
|
|
|
const userId = user().id |
|
|
|
|
|
|
|
|
|
|
|
sentry(() => sentryEnabled, userId) |
|
|
|
|
|
|
|
|
const killInternalProcess = () => { |
|
|
const killInternalProcess = () => { |
|
|
if (internalProcess) { |
|
|
if (internalProcess) { |
|
|
logger.log('killing internal process...') |
|
|
logger.log('killing internal process...') |
|
@ -30,7 +37,12 @@ const forkBundlePath = path.resolve(__dirname, `${__DEV__ ? '../../' : './'}dist |
|
|
const bootInternalProcess = () => { |
|
|
const bootInternalProcess = () => { |
|
|
logger.log('booting internal process...') |
|
|
logger.log('booting internal process...') |
|
|
internalProcess = fork(forkBundlePath, { |
|
|
internalProcess = fork(forkBundlePath, { |
|
|
env: { ...process.env, LEDGER_LIVE_SQLITE_PATH }, |
|
|
env: { |
|
|
|
|
|
...process.env, |
|
|
|
|
|
LEDGER_LIVE_SQLITE_PATH, |
|
|
|
|
|
INITIAL_SENTRY_ENABLED: sentryEnabled, |
|
|
|
|
|
SENTRY_USER_ID: userId, |
|
|
|
|
|
}, |
|
|
}) |
|
|
}) |
|
|
internalProcess.on('message', handleGlobalInternalMessage) |
|
|
internalProcess.on('message', handleGlobalInternalMessage) |
|
|
internalProcess.on('exit', code => { |
|
|
internalProcess.on('exit', code => { |
|
@ -102,6 +114,13 @@ ipcMain.on('executeHttpQueryPayload', (event, payload) => { |
|
|
p.send({ type: 'executeHttpQueryPayload', payload }) |
|
|
p.send({ type: 'executeHttpQueryPayload', payload }) |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
ipcMain.on('sentryLogsChanged', (event, payload) => { |
|
|
|
|
|
sentryEnabled = payload.value |
|
|
|
|
|
const p = internalProcess |
|
|
|
|
|
if (!p) return |
|
|
|
|
|
p.send({ type: 'sentryLogsChanged', payload }) |
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
// TODO move this to "command" pattern
|
|
|
// TODO move this to "command" pattern
|
|
|
ipcMain.on('updater', (event, { type, data }) => { |
|
|
ipcMain.on('updater', (event, { type, data }) => { |
|
|
const handler = { |
|
|
const handler = { |
|
|