You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

28 lines
772 B

import { type UtilityProcess, utilityProcess } from 'electron';
import { url, serverPath } from './constant';
import logger from './logger';
let serverProcess: null | UtilityProcess = null;
export function initServerProcess() {
serverProcess =
url ||
utilityProcess.fork(serverPath, [], {
stdio: 'pipe',
});
serverProcess.on?.('spawn', () => {
serverProcess.stdout?.on('data', (data) => {
console.log(`serverProcess output: ${data}`);
logger.info(`serverProcess output: ${data}`);
});
serverProcess.stderr?.on('data', (data) => {
console.error(`serverProcess err: ${data}`);
logger.error(`serverProcess output: ${data}`);
});
});
}
export function quitServerProcess() {
url || serverProcess?.kill();
}