Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lowcode-electron
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
electron
lowcode-electron
Commits
e219ebcd
Commit
e219ebcd
authored
Aug 04, 2023
by
韵晨龙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 系统兼容
parent
a1fc4b62
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
55 deletions
+36
-55
java.exe
baseServer/jre/bin/java.exe
+0
-0
shell.js
src/command/shell.js
+20
-6
process.js
src/sevice/process.js
+16
-49
No files found.
baseServer/jre/bin/java.exe
0 → 100644
View file @
e219ebcd
File added
src/command/shell.js
View file @
e219ebcd
...
...
@@ -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
}
})
...
...
src/sevice/process.js
View file @
e219ebcd
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment