Cuberite Forum
[Solved] restart function doesn't work - Printable Version

+- Cuberite Forum (https://forum.cuberite.org)
+-- Forum: Cuberite (https://forum.cuberite.org/forum-4.html)
+--- Forum: Discussion (https://forum.cuberite.org/forum-5.html)
+--- Thread: [Solved] restart function doesn't work (/thread-2433.html)



[Solved] restart function doesn't work - xelor - 05-03-2016

Hey everyone!

I'm using Cuberite on a Banana pro with Bananian.

When I change settings I have to close and restart Cuberite.
But when I use the "Restart Server" button in webinterface or the "restart" command the server only stops and sont starts after that.

Whats my failure?

EDIT:
Second and third post solved my Problem.


RE: restart function dont works - LogicParrot - 05-03-2016

I can confirm this happens to me as well. Apparently, restart is not properly supported. It is not your fault.

In the meantime, I suggest you put Cuberite inside some wrapper script which restarts it whenever it exits:

Save this as wrapper.sh:
#!/bin/sh
while [ 1 -eq 1 ]; do
    ./cuberite
    echo "Restarting Cuberite in 10 seconds..."
    sleep 10
done

To start cuberite:
chmod +x wrapper.sh
./wrapper.sh



RE: restart function doesn't work - LogicParrot - 05-03-2016

The problem with the above script is that you cannot easily stop Cuberite when you really want to. Here's a slightly more sophisticated version:

#!/bin/sh
if [ -f stop.txt ]; then rm stop.txt; fi  # Remove stop.txt if it exists for some reason
while [ ! -f stop.txt  ]; do # Keep restarting cuberite until user creates stop.txt
    ./cuberite
    echo "Restarting Cuberite in 10 seconds..."
    sleep 10
done
rm stop.txt  # Clean up by removing stop.txt

If you stop Cuberite normally, it will restart.
If you create a file called stop.txt, and then stop Cuberite, it will actually stop.


RE: restart function doesn't work - Schwertspize - 05-03-2016

@LogicParrot just as I am reviewing my mind, you should be able to use exit codes. Like restart if exit code is non-zero (eg at interruptions through sigkill or sigsegv) but that wouldn't include a standard stop and therefore the restart. But has this anything to do with the line "couldn't notify input thread, hanging up or killing?" (not exactly sure about the second part part)

Anyway, in bash scripting the exit code of the last command is $? So you can check with test -n (AFAIK, not tested). See man test


RE: restart function doesn't work - xelor - 05-03-2016

(05-03-2016, 04:35 AM)LogicParrot Wrote: The problem with the above script is that you cannot easily stop Cuberite when you really want to. Here's a slightly more sophisticated version:

#!/bin/sh
if [ -f stop.txt ]; then rm stop.txt; fi  # Remove stop.txt if it exists for some reason
while [ ! -f stop.txt  ]; do # Keep restarting cuberite until user creates stop.txt
    ./cuberite
    echo "Restarting Cuberite in 10 seconds..."
    sleep 10
done
rm stop.txt  # Clean up by removing stop.txt

If you stop Cuberite normally, it will restart.
If you create a file called stop.txt, and then stop Cuberite, it will actually stop.

Thanks LogicParrot, this solved my problem!!
I had only to change "./cuberite" to "./Cuberite".
So now the restart of server works!!!Big Grin