Restart on crash

Discussion in 'Server & Community Management' started by AgentLV, Apr 26, 2015.

Thread Status:
Not open for further replies.
  1. Hello,
    I just can't find a way to have my server automatically restart on a crash and I am not a fan of mark2 and the remote toolkit isn't being updated and didn't really work the way I wanted it to on 1.8.3. I have tried all kinds of stuff and nothing works, but there must be a way? How do other server admins handle this? I would be really happy if someone could help me out.

    • Agree Agree x 1
  2. I do the following with a Windows .bat file:
    Code (Text):
    java.exe -Xms3072m -Xmx3072m -Dlog4j.configurationFile=log4j2.xml -jar craftbukkit.jar -o true
    timeout 10
    echo resuming server...
    goto begin
  3. This automatically starts the server when it is stopped, but not on a crash. I would also need something for linux and not for windows.

    What does -o do?
    #3 AgentLV, Apr 27, 2015
    Last edited: Apr 27, 2015
  4. Code (Text):
    while true
    Java -Xmx1024M -jar Spigot.jar
    sleep 5
    • Agree Agree x 1
  5. As long as the program terminates (instead of looping forever), that should restart it. Once, Multiverse-Inventories ran my server out of memory and it hung. But if the program crashes, it should restart.

    Now are you saying a Java program can crash the process which invoked it? That sounds like a bigger problem.

    '-o true' sets online mode to true.
    • Informative Informative x 1
  6. Usually WorldEdit would crash my server if I copied too munch blocks or something. This would hang up the minecraft process and I would need to kill the process(manually) and start the minecraft server, I would like to have this automatically.
  7. Crash report?
  8. I think you didn't read the first post...
  9. there isnt an crash report in the first post -_-
  10. He's not asking how to fix a crash, he wants the server to auto reboot after a crash.
    • Optimistic Optimistic x 1
  11. edit the sh file location in spigot.yml
  12. This isn't really working for me.
  13. I gotta script that restarts it...hang on.
  14. This one restarts mine if it crashes...Its Linux Script though...
    Code (Text):
    cd /home/eodcrafter/hub/
    while true
    echo "##########STARTING###########"
    java -server -Xmx3G -Xms3G -jar spigot.jar nogui
    echo "Restarting in:"
    for i in 5 4 3 2 1
    echo "$i..."
    sleep 1
    echo "Server Hub Restarting!"
  15. Just for clarification. You have a restart script, put the path to it in your spigot.yml and set restart-on-crash to true and this does not work for you?

    Anyway I think it is not a good idea to put a loop into the restart script.
    The restart script should be executed once Spigot detects a crash and stops itself.
    It might be a better idea to use such a script as a watchdog and constantly check if Spigot is still running.

    You could also add some checks if your server were frozen by using Spigot in a screen session and send a cheap command to it. Then tail ne latest.log if the server responded properly.

    #16 Krauti2, May 2, 2015
    Last edited: May 2, 2015
  16. Could you elaborate Please?
    • Creative Creative x 1
  17. Let's say there is no need for a loop in this script rather than saying it is a bad idea ;).

    In theory or commonly ran in a terminal your script should start a new instance of java every six seconds if Spigot allows to run multiple instances from the same server (did not test).
    If you use this script as restart script in your spigot.yml and it works for your it seems that Spigot does not allow to have multiple sessions or unlikely catches the loop.
    However after a crash the script still runs in background due to the endless loop till the next crash happens and the script would run again and stack up. Sure this would not have great impact at all, it's more some kind a "optical defect" ;).

    In my case my restart script just starts a new automatically detached screen session and exits afterwards.

    • Informative Informative x 1
  18. Code (Text):
    screen -dmS minecraft java -Xms1G -Xmx3G -jar spigot-1.8.jar nogui
    This is my and /restart works perfectly fine, but the restart on crash doesn't work. I only get "Attempting to restart with ./", but nothing happens.
    Loops also don't restart crashes, because the process is frozen not stopped.
    • Like Like x 1
  19. you dont need the nogui param
Thread Status:
Not open for further replies.