Gnu-Screen

將螢幕作為 Minecraft 伺服器的守護程序啟動

  • July 22, 2016

我製作了一個手動執行良好的腳本,但無法按照如何在啟動時啟動腳本文件中的描述執行它?. 我跑了update-rc.d -f minecraft.start defaults

這就是我/etc/init.d/minecraft.start的樣子

#!/bin/bash
case "$1" in
 start)
   screen -S minecraft.start /home/phirephoenix/minecraft/bukkitserver/start_server.sh
   echo "Server started on screen minecraft"
   ;;
 stop)
   screen -X -S minecraft.start kill
   echo "Server shutting down"
   ;;
 *)
   echo "Usage: /etc/init.d/minecraft.start {start|stop}"
   exit 1
   ;;

esac

exit 0
~

由於腳本有效,我不會添加它,因為它是預設設置。

這是我的啟動日誌/var/log/boot.log

Begin: Loading essential drivers ... done.
Begin: Running /scripts/init-premount ... done.
Begin: Mounting root file system ... Begin: Running /scripts/local-top ... done.
Begin: Running /scripts/local-premount ... done.
Begin: Running /scripts/local-bottom ... done.
done.
Begin: Running /scripts/init-bottom ... done.
fsck from util-linux 2.20.1
/dev/sda1: clean, 66452/4325376 files, 1205648/17301248 blocks
* Starting configure network device [ OK ]
* Starting Mount network filesystems [ OK ]
* Starting Failsafe Boot Delay [ OK ]
* Stopping Mount network filesystems [ OK ]
* Starting Bridge socket events into upstart [ OK ]
* Starting SMB/CIFS File Server [ OK ]
* Starting configure network device [ OK ]
* Stopping OpenSSH server [ OK ]
* Starting OpenSSH server [ OK ]
* Starting NetBIOS name server [ OK ]
* Starting Mount network filesystems [ OK ]
* Stopping Failsafe Boot Delay [ OK ]
* Starting configure network device [ OK ]
* Starting System V initialisation compatibility [ OK ]
* Stopping Mount network filesystems [ OK ]
* Starting SMB/CIFS File and Active Directory Server [ OK ]
* Stopping cold plug devices [ OK ]
* Stopping log initial device creation [ OK ]
* Starting enable remaining boot-time encrypted block devices [ OK ]
* Starting configure network device security [ OK ]
* Starting configure virtual network devices [ OK ]
* Stopping configure virtual network devices [ OK ]
* Starting save udev log and update rules [ OK ]
* Stopping save udev log and update rules [ OK ]
Skipping profile in /etc/apparmor.d/disable: usr.sbin.rsyslogd
* Starting AppArmor profiles [ OK ]
* Stopping System V initialisation compatibility [ OK ]
* Starting System V runlevel compatibility [ OK ]
* Starting ACPI daemon [ OK ]
* Starting save kernel messages [ OK ]
* Starting automatic crash report generation [ OK ]
* Starting regular background program processing daemon [ OK ]
* Starting deferred execution scheduler [ OK ]
* Stopping save kernel messages [ OK ]
* Starting CPU interrupts balancing daemon [ OK ]
* Starting crash report submission daemon [ OK ]
* Starting domain name service... bind9 [ OK ]

**<BIG BLANK AREA RIGHT HERE, DON'T GET IT>**

**[screen is terminating]**
**Server started on screen minecraft**
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
* Starting web server apache2 [ OK ]
* Stopping System V runlevel compatibility [ OK ]

它確實在 start 中執行了 echo,但它也說 screen 正在終止。

是什麼導致了這個問題?我執行 Ubuntu Server,它似乎screen已安裝並正在執行。

如此新的方法,使用新貴功能(或者我應該稱之為的)。經過一些簡短的Google搜尋後,我有點理解執行時級別的東西,它現在應該從我設置的四個執行時級別之一開始,或停止,在暫停/重啟等時。

/etc/init/bukkit.conf 的很像一個術士做的。所有的 # 都是為了評論而添加在這裡的,而不是在實際的腳本上。

description     "Bukktiserver"
author          "jthanto@fixedyour.net"

start on runlevel [2345]
stop on runlevel [016]

pre-start script
   echo " * Bukkitserver started"
   # I don't know if this does anything at all
end script

   exec sudo /home/phirephoenix/minecraft/bukkitserver/start_server.sh
   # Had to sudo, or else it would get permission denied. Any ideas?

現在我可以輸入 sudo start bukkit 來啟動伺服器,但它仍然不能自動執行。bukkit 在我身邊initctl listbukkit stop/waiting 對於所有想知道 bukkit 是我的世界伺服器軟體的人。)

所以。我使用 .conf 使其成為新貴服務,希望腳本執行而無需我做任何事情(在任何登錄之前自動執行)。要執行的實際 jarfile 在我的主文件夾中是否有問題?我真的不記得我的主文件夾是否加密,但它可能是。這會是個問題嗎?我是否必須使用符號連結或其他東西(如果符號連結幾乎就像快捷方式,但不是嗎?)

我在這裡想念什麼?

Ps:我也把螢幕啟動的東西去掉了,用update-rc.d去掉。

我不記得screen有守護程序模式,顯然它確實如此。更改以下螢幕行:

screen -dmS minecraft.start /home/phirephoenix/minecraft/bukkitserver/start_server.sh

新參數-dmS“Start as daemon: Screen session in detached mode.”,這是您已經在使用的-d -m和的組合。-S

引用自:https://unix.stackexchange.com/questions/110060