그래서 저는 매우 간단한 시작 스크립트가 있는 수정된 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'.
이를 요약하는 몇 가지 FAQ:
- 나는 노력했다수지정된 명령을 실행하려면 기본 사용자를 입력하세요.실행 시작지정된 동일한 디렉토리에작업 목록정상적으로 시작됩니다. 이 오류는 systemd로 시작할 때만 발생합니다.
- 모든 필수 파일과 디렉터리(Java 실행 파일 제외)는 작업 디렉터리 내에 있습니다.
- 작업 디렉토리의 소유자와 그룹은 다음과 같습니다.지정공장(어쨌든 지금은 777 라이센스를 가지고 있습니다.)
- 경로의 모든 디렉터리를 읽고 실행할 수 있습니다.지정공장
나는 누군가가 이 사소해 보이는 작업을 도와줄 수 있기를 바랍니다. 나는 바보일지도 모르지만 그것을 볼 수 없습니다.
답변1
@ilkkachu의 의견으로 문제가 해결되었습니다. 비슷한 문제가 있는 사람이 있으면 ExecStart
지시문의 큰따옴표를 확인하세요!