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

feat: 修改runtime启动方式

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