Commit e219ebcd authored by 韵晨龙's avatar 韵晨龙

feat: 系统兼容

parent a1fc4b62
......@@ -4,9 +4,8 @@ const kill = require('kill-port')
const detect = require('detect-port');
const { MESSAGE_TYPE } = require('../enum')
const { getContext } = require('../store/index')
const { cwd } = require('../utils')
const { ipcRenderer} = require('electron')
const { ipcRenderer } = require('electron')
const { cwd, isMac } = require('../utils')
const log = getContext().log
const port = 7012
......@@ -26,14 +25,29 @@ function javaServer() {
const shellPath = path.join(cwd(), 'baseServer')
log.info('正在启动JAVA服务')
shell.cd(shellPath)
let exePath = path.join('.', '/jre/bin/java')
if (!isMac()) {
exePath = exePath + '.exe'
}
log.info(shell.ls())
let child = null
if (!isMac()) {
child = shell.exec(exePath + ' -jar syc-paas-standalone-biz.jar -spring.config.location=file:./baseServer/config/boostrap.yml &', { async: true })
} else {
child = shell.exec('./jre/bin/java -jar syc-paas-standalone-biz.jar -spring.config.location=file:./baseServer/config/boostrap.yml &', { async: true })
}
const child = shell.exec('./jre/bin/java -jar syc-paas-standalone-biz.jar -spring.config.location=file:./baseServer/config/boostrap.yml &', { async: true })
let isStart = false
child.stdout.on('data', function (stdout) {
log.info(stdout)
log.info(stdout, '----')
if (stdout.includes('Started Application in') && !isStart) {
ipcRenderer.send("close",MESSAGE_TYPE.DESIGN);
if (!isMac()) {
process.send('close')
} else {
ipcRenderer.send("close", MESSAGE_TYPE.DESIGN);
}
isStart = true
}
})
......
......@@ -5,6 +5,8 @@ const { utilityProcess } = require('electron')
const { MESSAGE_TYPE } = require('../enum')
const { getContext } = require('../store')
const utils = require('../utils')
const { fork } = require('child_process')
const { cwd, } = require('../utils')
// 执行进程命令,需使用nodejs启动,否则会不可控
class ProcessActivity {
......@@ -27,20 +29,32 @@ class ProcessActivity {
if (args.length) {
forkParam = [shellPath, args]
}
const child = utilityProcess.fork(...forkParam)
utilityProcess.fork(...forkParam)
}
batchCommand(shellPath, args = [], cb) {
let forkParam = [shellPath]
if (args.length) {
forkParam = [shellPath, args]
}
const child = utilityProcess.fork(...forkParam)
let child = null
if (utils.isMac()) {
child = utilityProcess.fork(...forkParam)
} else {
child = fork(...forkParam)
}
child.on('message', (data) => {
const childParam = { data, child }
if (args.length || cb) {
return this.watchGlobalMsg(childParam, cb)
}
this.handleDefaultProcessEnd(childParam)
if (data === 'close') {
this.ctx.win.close()
}
})
}
......@@ -56,7 +70,6 @@ class ProcessActivity {
}
handleDefaultProcessEnd({ data, child }) {
console.log(data,'-----datadata');
if (data.start && data.type === MESSAGE_TYPE.DEVELOPMENT) {
const data = child.kill()
if (data) {
......@@ -72,51 +85,6 @@ class ProcessActivity {
process.exit(1)
})
}
// // 进程关闭
// processClose() {
// this.processArray.forEach(workData => {
// const work = workData.work
// work.on('disconnect', () => this.disconnect(work))
// work.on('exit', () => this.exit(work))
// work.on('error', () => this.error(workData))
// work.on('message', () => {
// if (msg.act == 'SUICIDE') {
// this.suicide()
// }
// })
// })
// }
// exit(work) {
// console.log('进程已退出' + work.process.pid)
// // this.kill(work.process.pid)
// }
// error(workData) {
// console.log('重启中...')
// // 进程重启
// this.batchCommand(workData.shellPath)
// }
// disconnect(work) {
// console.log(work.process.pid, 'disconnect')
// }
// kill(pid) {
// setTimeout(() => {
// console.log('进程关闭pid' + pid)
// process.kill(pid, 'SIGHUP')
// }, 2000);
// }
// suicide(work) {
// console.log('SUICIDE')
// work.disconnect()
// }
}
module.exports = ProcessActivity
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment