mirror of
https://github.com/TermoraDev/termora.git
synced 2026-01-16 02:12:58 +08:00
fix: linux won't restart
This commit is contained in:
@@ -6,6 +6,7 @@ import org.apache.commons.io.FileUtils
|
|||||||
import org.apache.commons.lang3.StringUtils
|
import org.apache.commons.lang3.StringUtils
|
||||||
import org.slf4j.LoggerFactory
|
import org.slf4j.LoggerFactory
|
||||||
import java.awt.Component
|
import java.awt.Component
|
||||||
|
import java.nio.file.Paths
|
||||||
import java.util.concurrent.atomic.AtomicBoolean
|
import java.util.concurrent.atomic.AtomicBoolean
|
||||||
import javax.swing.JOptionPane
|
import javax.swing.JOptionPane
|
||||||
import javax.swing.SwingUtilities
|
import javax.swing.SwingUtilities
|
||||||
@@ -21,6 +22,17 @@ class TermoraRestarter {
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
Restarter.setProcessHandler { ProcessHandle.current().pid().toInt() }
|
Restarter.setProcessHandler { ProcessHandle.current().pid().toInt() }
|
||||||
|
Restarter.setExecCommandsHandler { commands ->
|
||||||
|
val pb = ProcessBuilder(commands)
|
||||||
|
if (SystemInfo.isLinux) {
|
||||||
|
// 去掉链接库变量
|
||||||
|
pb.environment().remove("LD_LIBRARY_PATH")
|
||||||
|
}
|
||||||
|
pb.redirectOutput(ProcessBuilder.Redirect.DISCARD)
|
||||||
|
pb.redirectError(ProcessBuilder.Redirect.DISCARD)
|
||||||
|
pb.directory(Paths.get(System.getProperty("user.home")).toFile())
|
||||||
|
pb.start()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -112,9 +124,6 @@ class TermoraRestarter {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("startupCommand: ${startupCommand}")
|
|
||||||
log.info("apppath: ${Application.getAppPath()}")
|
|
||||||
|
|
||||||
if (SystemInfo.isWindows && startupCommand == null) {
|
if (SystemInfo.isWindows && startupCommand == null) {
|
||||||
if (log.isWarnEnabled) {
|
if (log.isWarnEnabled) {
|
||||||
log.warn("Restart not supported , ProcessHandle#info#command is null.")
|
log.warn("Restart not supported , ProcessHandle#info#command is null.")
|
||||||
|
|||||||
Reference in New Issue
Block a user