Neue Antwort erstellen

Das nächste Update wird am Mittwoch, dem 26. September 2018 gegen Abend verfügbar sein. Sorry für die große Verzögerung!

Neu erstellte Beiträge unterliegen der Moderation und werden erst sichtbar, wenn sie durch einen Moderator geprüft und freigeschaltet wurden.

Die letzte Antwort auf dieses Thema liegt mehr als 30 Tage zurück. Das Thema ist womöglich bereits veraltet. Bitte erstellen Sie ggf. ein neues Thema.

Informationen
Sicherheitsabfrage („reCAPTCHA“)
Nachricht
  • :)
  • :(
  • ;)
  • :P
  • ^^
  • :D
  • ;(
  • X(
  • :*
  • :|
  • 8o
  • =O
  • <X
  • ||
  • :/
  • :S
  • X/
  • 8)
  • ?(
  • :huh:
  • :rolleyes:
  • :love:
  • 8|
  • :cursing:
  • :thumbdown:
  • :thumbsup:
  • :thumbup:
  • :sleeping:
  • :whistling:
  • :evil:
  • :saint:
  • <3
  • :!:
  • :?:
Internet-Adressen werden automatisch erkannt und umgewandelt.
Smiley-Code wird in Ihrer Nachricht automatisch als Smiley-Grafik dargestellt.
Sie können BBCodes zur Formatierung Ihrer Nachricht nutzen.

Vorherige Beiträge 8

  • yahwho schrieb:

    I guess the easiest way around this is to schedule (via a plugin) a "clean shutdown" at say midnight.
    Yes, that would work. You can either create a plugin which sends the messages and shuts the server down, or alternatively you can just send input commands to the server process (e.g. "shutdown" to shutdown the server, or "say" or "yell" to send a message to all players). In case you create a script to handle the restart, the input commands may be handier (so there is no need to use the plugin API at all) :)
  • red51 schrieb:

    The only issue when spawning a new process from within the JVM is that it's treated as a child process. This means if the JVM is closed, all child processes will be killed as well :/ You can add shutdown hooks to the JVM though (and start a new process there), but they're still affected by the death of the JVM (it kinda works on Windows but becomes very awkward on Linux)...
    Thanks for that. I'm by no means knowledgeable about the real ins and outs of java. Still learning! :D

    So.

    I guess the easiest way around this is to schedule (via a plugin) a "clean shutdown" at say midnight.

    Then at, say 2 minutes past midnight set a Scheduled Task to run the server.

    :thumbup:
  • The only issue when spawning a new process from within the JVM is that it's treated as a child process. This means if the JVM is closed, all child processes will be killed as well :/ You can add shutdown hooks to the JVM though (and start a new process there), but they're still affected by the death of the JVM (it kinda works on Windows but becomes very awkward on Linux)...
  • Java-Quellcode

    1. import java.io.*;
    2. public class CmdTest {
    3. public static void main(String[] args) throws Exception {
    4. ProcessBuilder builder = new ProcessBuilder(
    5. "cmd.exe", "/c", "cd \"C:\\Program Files\\Microsoft SQL Server\" && dir");
    6. builder.redirectErrorStream(true);
    7. Process p = builder.start();
    8. BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
    9. String line;
    10. while (true) {
    11. line = r.readLine();
    12. if (line == null) { break; }
    13. System.out.println(line);
    14. }
    15. }
    16. }
    Alles anzeigen
    That's how I'm going to run a script from Java. 8)
  • yahwho schrieb:

    Now, firstly, is this already possible? In which case show me the way to Tipperary!
    Through the API you can shutdown the server but you cannot restart it after atm

    yahwho schrieb:

    Step 2, stop any new connections to the server (not sure if this is possible? maybe set max players to 0?)
    Well you can use the .setCancelled(true) method in the PlayerConnectEvent for this ;)

    yahwho schrieb:

    Step 4, restart server script (not sure how to automate via java? (which is preferable)
    There are some restart scripts on the forum but none for java, server restarts are moslty done via shell commands, not sure if SteamCMD has any options like that too :/
  • Shutting Down Server

    yahwho

    Hi, I would like to create an automated/controlled server shutdown. Now, firstly, is this already possible? In which case show me the way to Tipperary!

    What I would like to do is something similar to this:

    Step 1, global announcement to players that server is rebooting soon (easily done)
    Step 2, stop any new connections to the server (not sure if this is possible? maybe set max players to 0?)
    Step 3, after x period of time, kick any remaining players that are online (so that there are zero players online)
    Step 4, restart server script (not sure how to automate via java? (which is preferable)