だから私は非常に単純な起動スクリプトを持つ修正されたMinecraftサーバーを持っており、systemdを使ってサーバーを制御したいと思います。起動スクリプトは次のとおりです。
#!/bin/sh
# Server Launch Script
#
# Thrown together by Neeve in under five minutes, Public Domain
# https://github.com/Neeve01
#
# Fixed and added java version check by t0suj4, Public Domain
# https://github.com/t0suj4
# DO NOT EDIT UNLESS YOU KNOW WHAT YOU'RE DOING
FORGEJAR='forge-1.12.2-14.23.5.2860.jar'
JAVA_PARAMETERS=''
# these you can edit
MIN_RAM='2048M'
MAX_RAM='12000M'
# DO NOT EDIT ANYTHING PAST THIS LINE
LAUNCHPARAMS="-server -Xms$MIN_RAM -Xmx$MAX_RAM $JAVA_PARAMETERS -Dlog4j.configurationFile=log4j2_112-116.xml -jar $FORGEJAR nogui"
echo "Checking java version..."
echo
java -version
echo
echo "The expected java version is 1.8. Not higher, not lower."
echo
echo "Launching the server..."
echo
echo "> java $LAUNCHPARAMS"
java $LAUNCHPARAMS
echo
echo "- The server has stopped. If it's a crash, please read the output above."
echo
read -p "- Press Return to exit..." _
これはls-la作業サイクルディレクトリ:
drwxrwxrwx 15 nomifactory nomifactory 4096 Dec 24 13:14 .
drwxrwxr-x 7 mux mux 4096 Dec 24 01:18 ..
-rwxrwxrwx 1 nomifactory nomifactory 2 Dec 24 01:25 banned-ips.json
-rwxrwxrwx 1 nomifactory nomifactory 2 Dec 24 01:25 banned-players.json
drwxrwxrwx 3 nomifactory nomifactory 4096 Nov 9 22:43 bansoukou
-rwxrwxrwx 1 nomifactory nomifactory 1053 Nov 9 22:43 CHANGELOG.md
drwxrwxrwx 32 nomifactory nomifactory 4096 Dec 24 01:19 config
drwxrwxrwx 4 nomifactory nomifactory 4096 Nov 9 22:43 config-overrides
-rwxrwxrwx 1 nomifactory nomifactory 9375 Dec 24 12:38 crafttweaker.log
-rwxrwxrwx 1 nomifactory nomifactory 180 Dec 24 01:20 eula.txt
-rwxrwxrwx 1 nomifactory nomifactory 4466148 Nov 9 22:42 forge-1.12.2-14.23.5.2860.jar
drwxrwxrwx 3 nomifactory nomifactory 4096 Dec 24 01:25 journeymap
-rwxrwxrwx 1 nomifactory nomifactory 916 Nov 9 22:43 launch.bat
-rwxrwxrwx 1 nomifactory nomifactory 897 Dec 24 01:30 launch.sh
drwxrwxrwx 7 nomifactory nomifactory 4096 Nov 9 22:42 libraries
-rwxrwxrwx 1 nomifactory nomifactory 7817 Nov 9 22:43 LICENSE.md
drwxrwxrwx 4 nomifactory nomifactory 4096 Dec 24 01:20 local
-rwxrwxrwx 1 nomifactory nomifactory 1159 Nov 9 22:43 log4j2_112-116.xml
drwxrwxrwx 2 nomifactory nomifactory 4096 Dec 24 02:38 logs
-rwxrwxrwx 1 nomifactory nomifactory 30222121 Feb 11 2022 minecraft_server.1.12.2.jar
drwxrwxrwx 3 nomifactory nomifactory 4096 Dec 24 01:19 .mixin.out
drwxrwxrwx 4 nomifactory nomifactory 12288 Dec 24 01:19 mods
-rwxrwxrwx 1 nomifactory nomifactory 2 Dec 24 01:25 ops.json
-rwxrwxrwx 1 nomifactory nomifactory 15 Dec 24 01:20 options.txt
drwxrwxrwx 2 nomifactory nomifactory 4096 Dec 24 01:20 patchouli_books
-rwxrwxrwx 1 nomifactory nomifactory 702 Nov 9 22:42 README.md
drwxrwxrwx 3 nomifactory nomifactory 4096 Nov 9 22:43 scripts
-rwxrwxrwx 1 nomifactory nomifactory 752 Dec 24 01:25 server.properties
drwxrwxrwx 2 nomifactory nomifactory 4096 Dec 24 01:21 TombManyGraves
-rwxrwxrwx 1 nomifactory nomifactory 2 Dec 24 01:25 usercache.json
-rwxrwxrwx 1 nomifactory nomifactory 2 Dec 24 01:25 whitelist.json
drwxrwxrwx 13 nomifactory nomifactory 4096 Dec 24 01:27 world
私はこのために次のような単位ファイルを作成しました。
[Unit]
Description=Nomifactory Server
After=network.target
[Service]
Type=simple
User=nomifactory
Group=nomifactory
Nice=1
KillSignal=SIGTERM
WorkingDirectory=/home/mux/mcs/nomifactory
ExecStart="/usr/bin/java -server -Xms2048M -Xmx12000M -Dlog4j.configurationFile=log4j2_112-116.xml -jar forge-1.12.2-14.23.5.2860.jar nogui"
#ExecStart=/usr/local/bin/nomifactory
[Install]
WantedBy=multi-user.target
サービスを開始しようとすると、次のエラーで失敗します(journalctlから取得)。
Dec 24 12:56:02 johann-serve systemd[1]: Started Nomifactory Server.
-- Subject: A start job for unit nomifactory.service has finished successfully
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- A start job for unit nomifactory.service has finished successfully.
--
-- The job identifier is 232408.
Dec 24 12:56:02 johann-serve systemd[2579244]: nomifactory.service: Failed to execute command: No such file or directory
Dec 24 12:56:02 johann-serve systemd[2579244]: nomifactory.service: Failed at step EXEC spawning /usr/bin/java -server -Xms2048M -Xmx12000M -Dlog4j.configurationFile=log4j2_112-116.xml -jar forge-1.12.2-14.23.5.2860.jar nogui: No such file or directory
-- Subject: Process /usr/bin/java -server -Xms2048M -Xmx12000M -Dlog4j.configurationFile=log4j2_112-116.xml -jar forge-1.12.2-14.23.5.2860.jar nogui could not be executed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- The process /usr/bin/java -server -Xms2048M -Xmx12000M -Dlog4j.configurationFile=log4j2_112-116.xml -jar forge-1.12.2-14.23.5.2860.jar nogui could not be executed and failed.
--
-- The error number returned by this process is ERRNO.
Dec 24 12:56:02 johann-serve systemd[1]: nomifactory.service: Main process exited, code=exited, status=203/EXEC
-- Subject: Unit process exited
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- An ExecStart= process belonging to unit nomifactory.service has exited.
--
-- The process' exit code is 'exited' and its exit status is 203.
Dec 24 12:56:02 johann-serve systemd[1]: nomifactory.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- The unit nomifactory.service has entered the 'failed' state with result 'exit-code'.
これを要約するいくつかのよくある質問:
- 頑張った数指定したコマンドを実行するには、デフォルトのユーザーを入力してください。実行開始指定された同じディレクトリにタスクリスト正常に起動します。このエラーは、systemdで始まる場合にのみ発生します。
- すべての必須ファイルとディレクトリ(Java実行可能ファイルを除く)は作業ディレクトリ内にあります。
- 作業ディレクトリの所有者とグループは次のとおりです。指定工場(とにかく今は777ライセンスを持っています。)
- パス内のすべてのディレクトリを読み取って実行できます。指定工場
私は誰かがこの些細な仕事を手伝ってくれることを願っています。バカかもしれませんが、見えません。
答え1
@ilkkachuのコメントで問題が解決しました。同様の問題がある人がいる場合は、ExecStart
ディレクティブの二重引用符を確認してください。