Pocketmine-MP非公式日本語wikiです。Pocketmine-MPに関する情報を発信しています。

サーバーを自動再起動してくれるプラグインを紹介します

フォーラムダウンロードリンク

Automatic Server Restarter
まずフォーラムでダウンロードしてプラグインファイルに入れます

テキストエディタでStart.cmdを編集します

編集前

@echo off
TITLE PocketMine-MP server software for Minecraft: Pocket Edition
cd /d %~dp0
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% %*
	)
#)

編集後

@echo off
TITLE Pocketmine-MP: Auto restart
cd /d %~dp0
netstat -o -n -a | findstr 0.0.0.0:19132>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:19132>nul
if %ERRORLEVEL% equ 0 (
    echo Server is running.
    goto :loop
) ELSE (
    echo Starting PocketMine-MP in 10 seconds...
    PING 127.0.0.1 -n 10 >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

Start.cmdの編集が終わったら起動させましょう

20:59:59 [INFO] Enabling ASR v2.0.1
20:59:59 [INFO] [ASR] It Seems you're new in using ASR.
20:59:59 [INFO] [ASR] Applying Configurations [...]
20:59:59 [INFO] [ASR] Note: Logger is disabled by default.
20:59:59 [INFO] [ASR] You can Enable it by editing the config.yml
20:59:59 [INFO] [ASR] If you have enabled Logger, please
20:59:59 [INFO] [ASR] use the proper MySQL Server info otherwise plugin wont work.
成功したらこのようにコンソール表示されるはずです

自動再起動の時間の設定は /asr <時間> で設定できます
再起動までの時間の確認は /restart で確認できます

ClearSkyなどをご使用の場合

Start.shの場合(Mac、Linuxなど)


編集前
#!/bin/bash

# This is start.sh file for Genisys #
# Please input ./start.sh to start server #

# Variable define
DIR="$(cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"

# Change Directory
cd "$DIR"

# Loop starting
# Do not edit without knowing what are you doing!

DO_LOOP="no"

##########################################
# DO NOT EDIT ANYTHING BEHIND THIS LINE! #
##########################################

while getopts "p:f:l" OPTION 2> /dev/null; do
	case ${OPTION} in
		p)
			PHP_BINARY="$OPTARG"
			;;
		f)
			POCKETMINE_FILE="$OPTARG"
			;;
		l)
			DO_LOOP="no"
			;;
		\?)
			break
			;;
	esac
done

if [ "$PHP_BINARY" == "" ]; then
	if [ -f ./bin/php7/bin/php ]; then
		export PHPRC=""
		PHP_BINARY="./bin/php7/bin/php"
	elif type php 2>/dev/null; then
		PHP_BINARY=$(type -p php)
	else
		echo "[ERROR] Couldn't find a working PHP binary, please use the installer."
		exit 1
	fi
fi

if [ "$POCKETMINE_FILE" == "" ]; then
	if [ -f ./PocketMine-iTX.phar ]; then
		POCKETMINE_FILE="./PocketMine-iTX.phar"
	elif [ -f ./Genisys*.phar ]; then
	    POCKETMINE_FILE="./Genisys*.phar"
	elif [ -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 "[ERROR] Couldn't find a valid Genisys 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" $@
	else
		exec "$PHP_BINARY" "$POCKETMINE_FILE" $@
	fi
	((LOOPS++))
done

if [ ${LOOPS} -gt 1 ]; then
	echo "[INFO] Restarted $LOOPS times"
fi


編集後(始めのDO_LOOP="no"をDO_LOOP="yes"にするだけです)
#!/bin/bash

# This is start.sh file for Genisys #
# Please input ./start.sh to start server #

# Variable define
DIR="$(cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd)"

# Change Directory
cd "$DIR"

# Loop starting
# Do not edit without knowing what are you doing!

DO_LOOP="yes"

##########################################
# DO NOT EDIT ANYTHING BEHIND THIS LINE! #
##########################################

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/php7/bin/php ]; then
		export PHPRC=""
		PHP_BINARY="./bin/php7/bin/php"
	elif type php 2>/dev/null; then
		PHP_BINARY=$(type -p php)
	else
		echo "[ERROR] Couldn't find a working PHP binary, please use the installer."
		exit 1
	fi
fi

if [ "$POCKETMINE_FILE" == "" ]; then
	if [ -f ./PocketMine-iTX.phar ]; then
		POCKETMINE_FILE="./PocketMine-iTX.phar"
	elif [ -f ./Genisys*.phar ]; then
	    POCKETMINE_FILE="./Genisys*.phar"
	elif [ -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 "[ERROR] Couldn't find a valid Genisys 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" $@
	else
		exec "$PHP_BINARY" "$POCKETMINE_FILE" $@
	fi
	((LOOPS++))
done

if [ ${LOOPS} -gt 1 ]; then
	echo "[INFO] Restarted $LOOPS times"
fi


これ以降はWindowsと同じなので省略します


以上です
閲覧ありがとうございました
お疲れ様でした

メニュー

トップページ
メンバー募集メンバーページ

カウンター

訪問者数

アクセス数

フリーエリア



メンバーのみ編集できます