Solved Autorestart script won't work

GLMidnight

New member
Jan 26, 2024
2
0
1
18
glmidnight.co.uk
(My post got deleted on Spigot Forums, so posting here. Sorry if I posted on the wrong forum or anything, I haven't used this before)

I'm having trouble getting auto-restart to work. This is my "ServerRestartScript.sh":
Java:
#!/bin/sh
java -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1NewSizePercent=30 -XX:G1MaxNewSizePercent=40 -XX:G1HeapRegionSize=8M -XX:G1ReservePercent=20 -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -Xmx11264M -Xms1024M -jar paper-1.20.4-399.jar nogui
However, that .sh file did not load when I used "/restart" and instead, it just stopped. So what I did was look for a solution and apparantley, this was the solution:

I made another sh file called "server.sh":
Java:
screen -x -R minecraft sh ./ServerRestartScript.sh
Then I configured it in spigot.yml:
YAML:
settings:
timeout-time: 60
restart-on-crash: true
restart-script: ./server.sh
So surely it should work right? As that helped people out? No. As I go to '/restart' my server, it just stops and doesn't give me an error to say why it won't restart. So exactly the same result as how it was when I just ran ./ServerRestartScript.sh
Code:
> restarrestart
[10:43:47 INFO]: [STDOUT] [org.spigotmc.RestartCommand] Attempting to restart with ./server.sh
>
[10:43:47 INFO]: Stopping server
(...plugins unloading)
[10:43:51 INFO]: Saving players
[10:43:52 INFO]: Saving worlds
[10:43:52 INFO]: Saving chunks for level 'ServerLevel[world]'/minecraft:overworld
[10:43:52 INFO]: [ChunkHolderManager] Waiting 60s for chunk system to halt for world 'world'
[10:43:52 INFO]: [ChunkHolderManager] Halted chunk system for world 'world'
[10:43:52 INFO]: [ChunkHolderManager] Saving all chunkholders for world 'world'
[10:43:52 INFO]: [ChunkHolderManager] Saved 529 block chunks, 529 entity chunks, 0 poi chunks in world 'world' in 0.81s
[10:43:52 INFO]: ThreadedAnvilChunkStorage (world): All chunks are saved
[10:43:52 INFO]: Saving chunks for level 'ServerLevel[world_nether]'/minecraft:the_nether
[10:43:52 INFO]: [ChunkHolderManager] Waiting 60s for chunk system to halt for world 'world_nether'
[10:43:52 INFO]: [ChunkHolderManager] Halted chunk system for world 'world_nether'
[10:43:52 INFO]: [ChunkHolderManager] Saving all chunkholders for world 'world_nether'
[10:43:53 INFO]: [ChunkHolderManager] Saved 529 block chunks, 529 entity chunks, 0 poi chunks in world 'world_nether' in 0.60s
[10:43:53 INFO]: ThreadedAnvilChunkStorage (DIM-1): All chunks are saved
[10:43:53 INFO]: Saving chunks for level 'ServerLevel[world_the_end]'/minecraft:the_end
[10:43:53 INFO]: [ChunkHolderManager] Waiting 60s for chunk system to halt for world 'world_the_end'
[10:43:53 INFO]: [ChunkHolderManager] Halted chunk system for world 'world_the_end'
[10:43:53 INFO]: [ChunkHolderManager] Saving all chunkholders for world 'world_the_end'
[10:43:53 INFO]: [ChunkHolderManager] Saved 529 block chunks, 529 entity chunks, 0 poi chunks in world 'world_the_end' in 0.17s
[10:43:53 INFO]: ThreadedAnvilChunkStorage (DIM1): All chunks are saved
[10:43:53 INFO]: ThreadedAnvilChunkStorage: All dimensions are saved
[10:43:53 INFO]: Flushing Chunk IO
[10:43:53 INFO]: Closing Thread Pool
> 2024-01-26 10:43:53,685 Log4j2-AsyncAppenderEventDispatcher-1-Async WARN Advanced terminal features are not available in this environment
[10:43:53 INFO]: Closing Server
It just doesn't make sense to me, as reading about 'screen' from this source, it would open a separate terminal instance within a single terminal manager (like a new tab on your browser), so I don't know why that wouldn't work, unless the Java server software was running already when it was starting to close itself, and maybe it didn't like that? No idea.

I'm using PaperSpigot 1.20.4, on a VPS at server.pro. I do have root access to it, however, meaning I could potentially run a command (since there's a built-in scheduler too) that'd check if the Minecraft service is running, and if not, it'd run.

My Minecraft server's directory:

/pro/minecraft-1/paper-1.20.4-399.jar

bnar7b.png

However, I'm not sure if that'll cause some issues as if it was to already be running, it'd probably still try? Or at least close the other server instance (meaning players would get kicked and get annoyed)?

I need it to work as I do have an auto-restarter feature turned on in this plugin (GeyserUpdater):
zwjiic.png

However, that'd just do /restart and that'd stop the server, once again. By the way, that plugin did create the script. The regular start.sh script didn't work anyway.

EDIT:

I have made both scripts run as programs, as it was set to off before for some reason. However, that didn't work too. I've attached the gif (it won't upload via link on this forum's proxy to act as a embed or however it works, so using the built-in feature).
 

Attachments

  • nhriat.gif
    nhriat.gif
    7.8 MB · Views: 2
Last edited:

GLMidnight

New member
Jan 26, 2024
2
0
1
18
glmidnight.co.uk
Found the solution. It turns out that some hosts (like server.pro) do not support SH scripts; which in itself is very annoying (and for some reason the directory keeps changing), so that explains why I couldn’t do other ways (loading up start.sh directly when the server's not on). I contacted support about this before I posted here, and they just told me to use their built-in scheduler (which defeats my point of it restarting when it crashes as that’s literally what I want). I would’ve been ok with that if they had an option to automatically start if it crashes. It’s a shame because they’ve changed their business model from just hosting Minecraft and Terraria servers to hosting Virtual Private Servers with game servers. It could have really worked, so I’ve given it another try and all seemed good except that, which is not good.

PebbleHost seems to be the best option, and I should’ve just stuck to that tbh. I have switched to there yesterday and it is all working well (along with a working start.sh script). Just remember, if your sh doesn’t work, ITS GOTTA BE YOUR HOST. (You can usually tell by adding in echo (text), and if it doesn’t come up with that when you /restart, your host definitely doesn’t support sh scripts, therefore switch hosts)

Here I’ve attached their messages.
 

Attachments

  • IMG_4414.png
    IMG_4414.png
    209 KB · Views: 4
  • IMG_4415.png
    IMG_4415.png
    220.1 KB · Views: 4