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

feat: 修改runtime启动方式

parent 94452185
......@@ -36,7 +36,6 @@ function javaServer(javaPath) {
// to do somethink
function runtimeServer() {
const javaPath = process.argv[process.argv.length - 1]
detect(port)
.then(_port => {
if (port == _port) {
......@@ -50,7 +49,5 @@ function runtimeServer() {
});
}
// runtimeServer()
module.exports = {
runtimeServer
}
runtimeServer()
......@@ -33,7 +33,7 @@ function javaServer() {
child.stdout.on('data', function (stdout) {
log.info(stdout)
if (stdout.includes('Started Application in') && !isStart) {
ipcRenderer.send("close");
ipcRenderer.send("close",MESSAGE_TYPE.DESIGN);
isStart = true
}
})
......
......@@ -32,7 +32,8 @@ exports.MAIN = {
exports.MESSAGE_TYPE = {
RUNTIME: 'RUNTIME',
DEVELOPMENT: 'DEVELOPMENT',
SUCCESS: 'SUCCESS'
SUCCESS: 'SUCCESS',
DESIGN: "DESIGN"
}
exports.DATA_BASE_MAP = {
DATABASE:'database',
......
......@@ -3,7 +3,7 @@ const { app, BrowserWindow, ipcMain } = require('electron')
const path = require('path')
const kill = require('kill-port')
const { MainEvent, Process } = require('./sevice/index')
const { MAIN, IPC } = require('./enum')
const { MAIN, IPC,MESSAGE_TYPE } = require('./enum')
const { setStore, getContext } = require('./store')
const utils = require('./utils')
const { handleMounted, handleClose } = require('./hook')
......@@ -97,10 +97,12 @@ class Main {
this.setWin(mainWindow)
// todo 这里有优化空间
ipcMain.on('close', () => {
ipcMain.on('close', (event,arg) => {
// 向渲染进程发送消息,通知前端进行相应的操作
mainWindow.webContents.send('close');
mainWindow && mainWindow.loadURL(this.IDEPage());
if(arg == MESSAGE_TYPE.DESIGN){
mainWindow.webContents.send('close');
mainWindow && mainWindow.loadURL(this.IDEPage());
}
});
}
return mainWindow
......
......@@ -7,6 +7,7 @@ const utils = require('../../../utils')
const open = require('open');
// I/O的异步性能比work_threads性能好,统一采用异步I/O
const { getContext } = require('../../../store')
const log = getContext().log
async function previewMounted(childProcess, ctx, url) {
// const cmd = utils.openUrlCmd(url)
......@@ -27,6 +28,7 @@ const onPlatform = {
const platFormPath = path.resolve(utils.getPlatDir(), platform)
let runtimeRelativePath = './deployment/bin/'
const startSh = path.resolve(platFormPath, runtimeRelativePath)
childProcess.batchCommand(runtimePath, [startSh], () => {
// 处理进程成功
// 'http://localhost:7018?platform=bigcode&previewTenantId=ADMIN_SYC&code=x0hRRhMc9Jqzw1jOyho4sg'
......
......@@ -18,24 +18,32 @@ class ProcessActivity {
this.index = null
this.pids = []
this.batchCommand(shellPath)
this.batchCommandForm(shellPath)
this.onKillProcess()
}
batchCommandForm(shellPath, args = [], cb) {
let forkParam = [shellPath]
if (args.length) {
forkParam = [shellPath, args]
}
const child = utilityProcess.fork(...forkParam)
}
batchCommand(shellPath, args = [], cb) {
let forkParam = [shellPath]
if (args.length) {
forkParam = [shellPath, args]
}
const child = utilityProcess.fork(...forkParam)
child.on('spawn', (data) => {
utils.time(() => {
const { mainEvent, win, log } = getContext()
mainEvent.sendApi.sendStart.startSucess(win)
}, 1500)
child.on('message', (data) => {
const childParam = { data, child }
if (args.length || cb) {
return this.watchGlobalMsg(childParam, cb)
}
this.handleDefaultProcessEnd(childParam)
})
}
/**
* 监听全局消息
* @param {Object} childParam
......
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