Added capability to prevent the normal stop command of the server
This commit is contained in:
parent
1915fc76a1
commit
ce7078ecad
@ -31,7 +31,7 @@ public class Startup {
|
||||
|
||||
/**
|
||||
* Initializes the logger with a new config instance.
|
||||
*
|
||||
*
|
||||
* @since Envoy Server Standalone v0.1-beta
|
||||
*/
|
||||
private static void initLogging() {
|
||||
@ -51,14 +51,15 @@ public class Startup {
|
||||
/**
|
||||
* Starts the server.
|
||||
*
|
||||
* @param args the run configuration. Currently unused.
|
||||
* @param args the run configuration. If it is "no-enter-to-stop" at position 0,
|
||||
* no command to read in an enter press will be generated
|
||||
* @throws IOException if the server crashes
|
||||
* @since Envoy Server Standalone v0.1-alpha
|
||||
*/
|
||||
public static void main(String[] args) throws IOException {
|
||||
initLogging();
|
||||
|
||||
Server server = new Server(8080, ObjectMessageReader::new,
|
||||
final Server server = new Server(8080, ObjectMessageReader::new,
|
||||
new ObjectMessageProcessor(Set.of(new LoginCredentialProcessor(),
|
||||
new MessageProcessor(),
|
||||
new GroupCreationProcessor(),
|
||||
@ -69,16 +70,18 @@ public class Startup {
|
||||
new ContactOperationProcessor())));
|
||||
|
||||
// Initialize the current message ID
|
||||
PersistenceManager persistenceManager = PersistenceManager.getInstance();
|
||||
final PersistenceManager persistenceManager = PersistenceManager.getInstance();
|
||||
if (persistenceManager.getConfigItemByID("currentMessageId") == null)
|
||||
persistenceManager.addConfigItem(new envoy.server.data.ConfigItem("currentMessageId", "0"));
|
||||
|
||||
server.start();
|
||||
server.getSocketProcessor().registerSocketIdListener(ConnectionManager.getInstance());
|
||||
|
||||
System.out.println("Press the return key to stop the server...");
|
||||
System.in.read();
|
||||
System.out.println("Stopped");
|
||||
System.exit(0);
|
||||
if (args.length == 0 || !args[0].equalsIgnoreCase("no-enter-to-stop")) {
|
||||
System.out.println("Press the return key to stop the server...");
|
||||
System.in.read();
|
||||
System.out.println("Stopped");
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user