Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Other ways to auto-restart a server

Comments in 'Plugin Development' started by Gamecrafter, Sep 13, 2015.

?

How do you get your server to automatically restart?

  1. Modifying start.cmd/start.sh

    64.3%
  2. Other methods

    35.7%
  1. da123rrell
    Offline

    da123rrell Active Member

    Joined:
    Feb 11, 2015
    Posts:
    136
    Minecraft User:
    da123rrell
  2. andre_the_gamer
    Offline

    andre_the_gamer Active Member

    Joined:
    Feb 5, 2015
    Posts:
    112
    Minecraft User:
    Andre_The_Gamer
  3. Andrey Nazarchuk
    Offline

    Andrey Nazarchuk Active Member

    Joined:
    Dec 30, 2013
    Posts:
    332
    Minecraft User:
    digita1eclipse
    What if he wants to restart his server whenever he wants and not just when it crashes?
  4. andre_the_gamer
    Offline

    andre_the_gamer Active Member

    Joined:
    Feb 5, 2015
    Posts:
    112
    Minecraft User:
    Andre_The_Gamer
    It can also be added in the Query.sh
  5. da123rrell
    Offline

    da123rrell Active Member

    Joined:
    Feb 11, 2015
    Posts:
    136
    Minecraft User:
    da123rrell
    or use ASR start script and type / stop to restart
  6. andre_the_gamer
    Offline

    andre_the_gamer Active Member

    Joined:
    Feb 5, 2015
    Posts:
    112
    Minecraft User:
    Andre_The_Gamer

    He can use the (ASR) plugin to stop server from period of time and he can use the Query.sh to restart with having to modify the start.sh from pocketmine
  7. Andrey Nazarchuk
    Offline

    Andrey Nazarchuk Active Member

    Joined:
    Dec 30, 2013
    Posts:
    332
    Minecraft User:
    digita1eclipse
    Yes it can but that only STARTS the server when it crashes or does not respond fast enough.

    That's not automatic!!! Not everyone has time to sit by all of their 10+ servers all the time and restart them.
  8. Andrey Nazarchuk
    Offline

    Andrey Nazarchuk Active Member

    Joined:
    Dec 30, 2013
    Posts:
    332
    Minecraft User:
    digita1eclipse
  9. da123rrell
    Offline

    da123rrell Active Member

    Joined:
    Feb 11, 2015
    Posts:
    136
    Minecraft User:
    da123rrell
    well use time commander like me. iset time commander to stop every 3 to 4 hours
  10. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Yea, only works with some control panels, not running local server on pc.
  11. andre_the_gamer
    Offline

    andre_the_gamer Active Member

    Joined:
    Feb 5, 2015
    Posts:
    112
    Minecraft User:
    Andre_The_Gamer
    Im running multicraft on my dedicated server' xD it took me ages to fix it so multicraft can suppport it.
  12. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Just start the server using `./start.sh -l` instead of `./start.sh`. That basically solves every problem. I simply don't know what's so hard with that.
  13. Primus
    Offline

    Primus Notable Member

    Joined:
    Apr 7, 2015
    Posts:
    1,470
    Minecraft User:
    PrimusLV
    Works with Linux right? But what with Windows or Mac?
  14. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Same for Mac, as long as you start the server using start.sh instead of start.cmd
    For Windows, it is more troublesome. Though, I believe you can write a script in another language that spawns a PocketMine server as a child process and watch it.
  15. da123rrell
    Offline

    da123rrell Active Member

    Joined:
    Feb 11, 2015
    Posts:
    136
    Minecraft User:
    da123rrell
    with windows? use this
    Code:
    @echo off
    TITLE Pocketmine-MP: Auto restart
    cd /d %~dp0
    netstat -o -n -a | findstr 0.0.0.0:11222>nul
    if %ERRORLEVEL% equ 0 (
        echo Your server is running.
        goto :loop
    ) ELSE (
        echo Starting your PocketMine-MP server.
        goto :StartPM
    )
    
    
    :loop
    echo Checking if server is online...
    PING 127.0.0.1 -n 10 >NUL
    
    
    netstat -o -n -a | findstr 0.0:11222>nul
    if %ERRORLEVEL% equ 0 (
        echo Server is running.
        goto :loop
    ) ELSE (
        echo Starting PocketMine-MP in 3 seconds...
        PING 127.0.0.1 -n 3 >NUL
        goto :StartPM
    )
    
    
    :StartPM
    if exist bin\php\php.exe (
        set PHP_BINARY=bin\php\php.exe
    ) else (
        set PHP_BINARY=php
    )
    
    if exist PocketMine-MP.phar (
        set POCKETMINE_FILE=PocketMine-MP.phar
    ) else (
        if exist src\pocketmine\PocketMine.php (
            set POCKETMINE_FILE=src\pocketmine\PocketMine.php
        ) else (
            echo "Couldn't find a valid PocketMine-MP installation"
            pause
            exit 1
        )
    )
    
    #if exist bin\php\php_wxwidgets.dll (
    #    %PHP_BINARY% %POCKETMINE_FILE% --enable-gui %*
    #) else (
        if exist bin\mintty.exe (
            start "" bin\mintty.exe -o Columns=88 -o Rows=32 -o AllowBlinking=0 -o FontQuality=3 -o Font="DejaVu Sans Mono" -o FontHeight=10 -o CursorType=0 -o CursorBlinks=1 -h error -t "PocketMine-MP" -i bin/pocketmine.ico -w max %PHP_BINARY% %POCKETMINE_FILE% --enable-ansi %*
        ) else (
            %PHP_BINARY% -c bin\php %POCKETMINE_FILE% %*
        )
    #)
    goto :loop
    PAUSE
    PEMapModder likes this.
  16. andre_the_gamer
    Offline

    andre_the_gamer Active Member

    Joined:
    Feb 5, 2015
    Posts:
    112
    Minecraft User:
    Andre_The_Gamer
    With linux use this" Put this into a sh with name: AutoRestart.sh make sure its in the same folder as pocketmine is installed

    Code:
    #!/bin/bash
    DIR="$(cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"
    cd "$DIR"
    DO_LOOP="yes"
    while getopts "p:f:l" OPTION 2> /dev/null; do
    case ${OPTION} in
    p)
    PHP_BINARY="$OPTARG"
    ;;
    f)
    POCKETMINE_FILE="$OPTARG"
    ;;
    l)
    DO_LOOP="yes"
    ;;
    \?)
    break
    ;;
    esac
    done
    if [ "$PHP_BINARY" == "" ]; then
    if [ -f ./bin/php5/bin/php ]; then
    export PHPRC=""
    PHP_BINARY="./bin/php5/bin/php"
    elif [ type php 2>/dev/null ]; then
    PHP_BINARY=$(type -p php)
    else
    echo "Couldn't find a working PHP binary, please use the installer."
    exit 1
    fi
    fi
    if [ "$POCKETMINE_FILE" == "" ]; then
    if [ -f ./PocketMine-MP.phar ]; then
    POCKETMINE_FILE="./PocketMine-MP.phar"
    elif [ -f ./src/pocketmine/PocketMine.php ]; then
    POCKETMINE_FILE="./src/pocketmine/PocketMine.php"
    else
    echo "Couldn't find a valid PocketMine-MP installation"
    exit 1
    fi
    fi
    LOOPS=0
    set +e
    while [ "$LOOPS" -eq 0 ] || [ "$DO_LOOP" == "yes" ]; do
    if [ "$DO_LOOP" == "yes" ]; then
    "$PHP_BINARY" "$POCKETMINE_FILE" [email protected]
    else
    exec "$PHP_BINARY" "$POCKETMINE_FILE" [email protected]
    fi
    ((LOOPS++))
    done
    if [ ${LOOPS} -gt 1 ]; then
    echo "Restarted $LOOPS times"
    fi
    
    
  17. Gamecrafter
    Offline

    Gamecrafter

    Joined:
    Nov 20, 2014
    Posts:
    978
    Plugins:
    9
    @Humerus said he rejected my plugin because of this(via private message):
    He said "shouldn't need to rewrite system files". I'm assuming he meant start.cmd/start.sh.
  18. da123rrell
    Offline

    da123rrell Active Member

    Joined:
    Feb 11, 2015
    Posts:
    136
    Minecraft User:
    da123rrell
    The problem is android pocketmine cant do it
  19. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    I just double click start.sh to run it (Mac).
  20. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    Yes I know, I was just saying that I don't use ./start.sh

Share This Page

Advertisement