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

Multi-Servers that restart automatically

Comments in 'Plugin Development' started by domybest, Oct 2, 2016.

  1. domybest
    Offline

    domybest New Member

    Joined:
    Dec 18, 2015
    Posts:
    7
    Minecraft User:
    Riceball_bro
    Hello PocketMine !
    I am holding one server using Windows Server 2012.
    This server will restart automatically in an hour. (using plugin RestartMe, the start.cmd is the RestartMe version)
    When the server restarted, the mintty.exe still existed.
    So I simply add the command "/f /im mintty.exe" in the start.cmd to kill the software.
    But when I tried to hold 2 or more servers, this command will kill the other servers.
    Also, the start.cmd will not restart server.
    The two servers have different ports and names.
    How to fix that?
    Sorry, bad English.
  2. Tim // robske Büba
    Offline

    Tim // robske Büba Notable Member

    Joined:
    Feb 26, 2014
    Posts:
    606
    Minecraft User:
    robske_110
    best solution: do not use windows
    second emergency-i-d-k-how-to-install-linux approach:
    is the server correctly shutting down? or is the php process stuck (probably at command reader, WINDOWS SUCKS). If the php process is stuck the only hack would be to let the server write their pids in a text file and then let the start.cmd read that out and directly kill only that php pid.

    If mintty.exe is stuck itself (what i don't think is what happens here) there is no quick solution (can we get the pid when we start a process?)
  3. TheDeibo
    Offline

    TheDeibo Notable Member Plugin Developer

    Joined:
    Sep 8, 2014
    Posts:
    692
    Plugins:
    1
    Minecraft User:
    TheDeibo
    You must end all php.exe
  4. domybest
    Offline

    domybest New Member

    Joined:
    Dec 18, 2015
    Posts:
    7
    Minecraft User:
    Riceball_bro
    Well, that's a problem...
    Because when I do that, the second server will be killed, too.
    (Killing all php.exe will kill all servers at the same time)
  5. TheDeibo
    Offline

    TheDeibo Notable Member Plugin Developer

    Joined:
    Sep 8, 2014
    Posts:
    692
    Plugins:
    1
    Minecraft User:
    TheDeibo
    Or add a automatic restart.

    Code:
    @echo off
    :start
    TITLE Pocketmine-MP: Auto restart
    cd /d %~dp0
    
    :loop
    echo Checking if server is online...
    PING 127.0.0.1 -n 3 >NUL
    netstat -o -n -a | findstr 0.0:25565>nul
    if %ERRORLEVEL% equ 0 (
        echo Server is running.
        goto :loop
    ) ELSE (
        call :StartPM
        goto :Exit
        call :StartPM
    )
    goto :EOF
    
    :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
        )
    )
    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% %*
    exit
        )
    )
    goto :loop
    goto :EOF
    
    :Exit
    exit
    Use this as the start.cmd

    in the code you will notice this
    Code:
    netstat -o -n -a | findstr 0.0:25565>nul
    
    Change the port of that to any port you want.

    and I suggest using this plugin. https://forums.pocketmine.net/plugins/automatic-server-restarter.903/

    :)
  6. domybest
    Offline

    domybest New Member

    Joined:
    Dec 18, 2015
    Posts:
    7
    Minecraft User:
    Riceball_bro
    I tried to use this way, but it didn't work well.
    The zombie mintty.exe still alive
    (The server was closed, but the mintty.exe still survived)
    What I want to do is to kill the target mintty.exe and hold multiple servers.
    (Not just kill them all)
    (Maybe when server is running, record the PID which uses the target port. When server is closed, kill the target PID)
    But I don't know how to do that in a .bat.
    Any help?
    Last edited: Oct 3, 2016
  7. TheDeibo
    Offline

    TheDeibo Notable Member Plugin Developer

    Joined:
    Sep 8, 2014
    Posts:
    692
    Plugins:
    1
    Minecraft User:
    TheDeibo
    So its the act of killing one server?
  8. Thunder33345
    Offline

    Thunder33345 Notable Member

    Joined:
    Apr 3, 2014
    Posts:
    755
    Minecraft User:
    Thunder33345
    Try kill them by their directory runned by
    that is if you use PM PHP Bin you could kill it by path
    example killing all processes running from path /thunder33345/servers/server1/*
    if that is even possible to do so
  9. TheDeibo
    Offline

    TheDeibo Notable Member Plugin Developer

    Joined:
    Sep 8, 2014
    Posts:
    692
    Plugins:
    1
    Minecraft User:
    TheDeibo
    I was going to look into that too just before you suggested it... but my wifi dipped...

Share This Page

Advertisement