2011-05-18 64 views
0

目前我開始一個Armagetron服務器與下面的腳本慶典:將這個腳本允許PHP解析器執行

#!/bin/sh 

tron="/home/duke/aa/bin/armagetronad-dedicated" 
var="/home/duke/aa/servers/demo/var/" 
log="${var}console_log.txt" 
userconfigdir="/home/duke/aa/servers/demo/var/customize/config/" 
parser="/home/duke/aa/scripts/parser.php" 
ladderlog="${var}ladderlog.txt" 
cmds="${var}cmd.txt" 

tail -n0 -f -s 0.01 $ladderlog | $parser | $tron --userconfigdir $userconfigdir --vardir $var | tee -a $log 

這將運行在服務器和$解析器applys PHP腳本

不過,我想開始我的服務器是這樣的:

#!/bin/bash 
    screen -S $1 -X quit # avoiding to run the same server twice 
screen -dmS $1 /home/duke/aa/scripts/srv $1  

SRV:

screen -S $1 -X logtstamp on 
screen -S $1 -X logfile /home/duke/aa/servers/$1/logs 
screen -S $1 -X log on 
while true; do # start a loop to allow server restart if it crashes 
/home/duke/aa/bin/armagetronad-dedicated --vardir /home/duke/aa/servers/$1/var --userdatadir /home/duke/aa/servers/$1/var/customize #run the server  

    echo "###Server has crashed. Ctrl-C to cancel reboot...###" 
    sleep 5 

done # end the loop 

這裏唯一的問題是我不知道如何指定一個php解析器在服務器上運行(我是一個noob)。我如何修改第二個腳本來允許這個?

+1

你可以通過運行「php -f /path/to/file.php」調用php運行一個文件 – fin1te 2011-05-18 11:23:10

+0

@ fin1te這是在srv腳本中還是在屏幕上使用了-dmS? – dukevin 2011-05-18 11:24:27

+0

如何知道PHP腳本會影響正在運行的服務器,而不是其他內容,比如shell? – dukevin 2011-05-18 11:29:47

回答

1

把所有的代碼在SRV腳本while循環中的第一個塊,即

SRV:

#!/bin/bash 
tron="/home/duke/aa/bin/armagetronad-dedicated" 
var="/home/duke/aa/servers/demo/var/" 
log="${var}console_log.txt" 
userconfigdir="/home/duke/aa/servers/demo/var/customize/config/" 
parser="/home/duke/aa/scripts/parser.php" 
ladderlog="${var}ladderlog.txt" 
cmds="${var}cmd.txt" 


screen -S $1 -X logtstamp on 
screen -S $1 -X logfile /home/duke/aa/servers/$1/logs 
screen -S $1 -X log on 
while true; do # start a loop to allow server restart if it crashes 
    tail -n0 -f -s 0.01 $ladderlog | $parser | $tron --userconfigdir $userconfigdir --vardir $var | tee -a $log 
    # /home/duke/aa/bin/armagetronad-dedicated --vardir /home/duke/aa/servers/$1/var --userdatadir /home/duke/aa/servers/$1/var/customize #run the server 

    echo "###Server has crashed. Ctrl-C to cancel reboot...###" 
    sleep 5 

done # end the loop 

(這是否正確?)

我希望這有助於。