Поправил restart.

This commit is contained in:
zaxar163 2019-01-03 17:27:26 +04:00
parent 68109c1ea3
commit 3374b06882
No known key found for this signature in database
GPG key ID: CEE900027AE098E0

View file

@ -2,9 +2,9 @@
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.BufferedWriter; import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.lang.ProcessBuilder.Redirect; import java.lang.ProcessBuilder.Redirect;
import java.lang.management.ManagementFactory;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.SocketAddress; import java.net.SocketAddress;
@ -12,7 +12,6 @@
import java.nio.file.FileVisitResult; import java.nio.file.FileVisitResult;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.SimpleFileVisitor; import java.nio.file.SimpleFileVisitor;
import java.nio.file.attribute.BasicFileAttributes; import java.nio.file.attribute.BasicFileAttributes;
import java.security.KeyPair; import java.security.KeyPair;
@ -75,7 +74,6 @@
import ru.gravit.launchserver.texture.RequestTextureProvider; import ru.gravit.launchserver.texture.RequestTextureProvider;
import ru.gravit.launchserver.texture.TextureProvider; import ru.gravit.launchserver.texture.TextureProvider;
import ru.gravit.utils.helper.CommonHelper; import ru.gravit.utils.helper.CommonHelper;
import ru.gravit.utils.helper.EnvHelper;
import ru.gravit.utils.helper.IOHelper; import ru.gravit.utils.helper.IOHelper;
import ru.gravit.utils.helper.JVMHelper; import ru.gravit.utils.helper.JVMHelper;
import ru.gravit.utils.helper.LogHelper; import ru.gravit.utils.helper.LogHelper;
@ -142,6 +140,8 @@ public static final class Config {
public boolean isWarningMissArchJava; public boolean isWarningMissArchJava;
public String startScript;
public String getAddress() { public String getAddress() {
return address; return address;
@ -564,6 +564,7 @@ private void generateConfigIfNotExists() throws IOException {
newConfig.launch4j.productVer = newConfig.launch4j.fileVer; newConfig.launch4j.productVer = newConfig.launch4j.fileVer;
newConfig.buildPostTransform = new PostBuildTransformConf(); newConfig.buildPostTransform = new PostBuildTransformConf();
newConfig.env = LauncherConfig.LauncherEnvironment.STD; newConfig.env = LauncherConfig.LauncherEnvironment.STD;
newConfig.startScript = "." + File.separator + "start.sh";
newConfig.authHandler = new MemoryAuthHandler(); newConfig.authHandler = new MemoryAuthHandler();
newConfig.hwidHandler = new AcceptHWIDHandler(); newConfig.hwidHandler = new AcceptHWIDHandler();
@ -688,10 +689,7 @@ public void syncUpdatesDir(Collection<String> dirs) throws IOException {
public void restart() { public void restart() {
ProcessBuilder builder = new ProcessBuilder(); ProcessBuilder builder = new ProcessBuilder();
List<String> args = new ArrayList<>(); List<String> args = new ArrayList<>();
args.add(IOHelper.resolveJavaBin(Paths.get(System.getProperty("java.home"))).toString()); args.add(config.startScript);
args.addAll(ManagementFactory.getRuntimeMXBean().getInputArguments());
args.addAll(args);
EnvHelper.addEnv(builder);
builder.directory(this.dir.toFile()); builder.directory(this.dir.toFile());
builder.inheritIO(); builder.inheritIO();
builder.redirectErrorStream(true); builder.redirectErrorStream(true);
@ -704,7 +702,7 @@ public void restart() {
} }
public void fullyRestart() { public void fullyRestart() {
server.restart(); restart();
JVMHelper.RUNTIME.exit(0); JVMHelper.RUNTIME.exit(0);
} }
} }