forked from 2009Scape/Server
Make shutdown work properly + add TICK modifier
This commit is contained in:
parent
7cd02df358
commit
4ef73827cf
24 changed files with 21 additions and 18 deletions
|
|
@ -22,6 +22,11 @@ import java.util.Scanner;
|
|||
*/
|
||||
public final class Management {
|
||||
|
||||
/**
|
||||
* If the shutdown hook is active.
|
||||
*/
|
||||
public static boolean active = true;
|
||||
|
||||
/**
|
||||
* The commands.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package org.keldagrim.classloader;
|
||||
|
||||
import org.keldagrim.Management;
|
||||
import org.keldagrim.ServerConstants;
|
||||
|
||||
import java.io.File;
|
||||
|
|
@ -52,7 +53,7 @@ public class ClassLoadServer extends Thread {
|
|||
public void run() {
|
||||
resetResourceCache();
|
||||
// System.out.println("Listening on port " + PORT + "...");
|
||||
while (true) {
|
||||
while (Management.active) {
|
||||
Socket clientSocket = null;
|
||||
try {
|
||||
clientSocket = serverSocket.accept();
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package org.keldagrim.net;
|
||||
|
||||
import org.keldagrim.Management;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.channels.SelectionKey;
|
||||
|
|
@ -86,7 +88,7 @@ public final class NioReactor implements Runnable {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
while (running) {
|
||||
while (running && Management.active) {
|
||||
try {
|
||||
selector.select();
|
||||
} catch (IOException e) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
package org.keldagrim.system;
|
||||
|
||||
|
||||
import org.keldagrim.Management;
|
||||
|
||||
/**
|
||||
* The shutdown sequence used for safely turning off the Management server.
|
||||
* @author Emperor
|
||||
|
|
@ -8,14 +10,9 @@ package org.keldagrim.system;
|
|||
*/
|
||||
public final class ShutdownSequence extends Thread {
|
||||
|
||||
/**
|
||||
* If the shutdown hook is active.
|
||||
*/
|
||||
private static boolean active = true;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (active) {
|
||||
if (Management.active) {
|
||||
shutdown();
|
||||
}
|
||||
}
|
||||
|
|
@ -25,7 +22,6 @@ public final class ShutdownSequence extends Thread {
|
|||
*/
|
||||
public static void shutdown() {
|
||||
System.out.println("Management server successfully shut down!");
|
||||
active = false;
|
||||
System.exit(0);
|
||||
Management.active = false;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue