Add an API to restart with a specific script.

This commit is contained in:
md_5 2014-05-24 17:10:15 +10:00
parent 7fcaf3f2c7
commit 1bbcf1c272

View File

@ -1,4 +1,4 @@
From 51fd2b3d6dc835f75d76f5a6729293f6e8768cdf Mon Sep 17 00:00:00 2001
From 9887296b1b8adebbcdb19f7ab2e2eea28f6810d3 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Sat, 23 Feb 2013 12:33:20 +1100
Subject: [PATCH] Watchdog Thread.
@ -26,10 +26,10 @@ index 007fb86..51f1761 100644
}
diff --git a/src/main/java/org/spigotmc/RestartCommand.java b/src/main/java/org/spigotmc/RestartCommand.java
new file mode 100644
index 0000000..3e4203f
index 0000000..5fa56c0
--- /dev/null
+++ b/src/main/java/org/spigotmc/RestartCommand.java
@@ -0,0 +1,113 @@
@@ -0,0 +1,117 @@
+package org.spigotmc;
+
+import java.io.File;
@ -62,11 +62,15 @@ index 0000000..3e4203f
+
+ public static void restart()
+ {
+ restart( new File( SpigotConfig.restartScript ) );
+ }
+
+ public static void restart(File script)
+ {
+ AsyncCatcher.enabled = false; // Disable async catcher incase it interferes with us
+ try
+ {
+ final File file = new File( SpigotConfig.restartScript );
+ if ( file.isFile() )
+ if ( script.isFile() )
+ {
+ System.out.println( "Attempting to restart with " + SpigotConfig.restartScript );
+
@ -115,12 +119,12 @@ index 0000000..3e4203f
+ String os = System.getProperty( "os.name" ).toLowerCase();
+ if ( os.contains( "win" ) )
+ {
+ Runtime.getRuntime().exec( "cmd /c start " + file.getPath() );
+ Runtime.getRuntime().exec( "cmd /c start " + script.getPath() );
+ } else
+ {
+ Runtime.getRuntime().exec( new String[]
+ {
+ "sh", file.getPath()
+ "sh", script.getPath()
+ } );
+ }
+ } catch ( Exception e )