2016-11-29 6 views
0

Ich versuche, ein init.d-Skript für meine screps privaten Server zu erstellen. Ich habe Probleme mit ein paar Dingen.Screeps private Serverkonfiguration init.d

  1. Ich möchte screeps mit einem Daemon Benutzer ausführen nicht root screeps-daemon
  2. ich sicherstellen wollen, dass es in der richtigen Arbeitsverzeichnis ausgeführt wird.

initd-forever Verwendung erzeugt ich folgendes:

#!/bin/bash 
### BEGIN INIT INFO 
# If you wish the Daemon to be lauched at boot/stopped at shutdown : 
# 
# On Debian-based distributions: 
#  INSTALL : update-rc.d scriptname defaults 
#  (UNINSTALL : update-rc.d -f scriptname remove) 
# 
# On RedHat-based distributions (CentOS, OpenSUSE...): 
#  INSTALL : chkconfig --level 35 scriptname on 
#  (UNINSTALL : chkconfig --level 35 scriptname off) 
# 
# chkconfig:   2345 90 60 
# Provides:   /usr/local/bin/screeps 
# Required-Start: $remote_fs $syslog 
# Required-Stop:  $remote_fs $syslog 
# Default-Start:  2 3 4 5 
# Default-Stop:  0 1 6 
# Short-Description: forever running /usr/local/bin/screeps 
# Description:  /usr/local/bin/screeps 
### END INIT INFO 
# 
# initd a node app 
# Based on a script posted by https://gist.github.com/jinze at https://gist.github.com/3748766 
# 

if [ -e /lib/lsb/init-functions ]; then 
    # LSB source function library. 
    . /lib/lsb/init-functions 
fi; 

pidFile="/var/run/forever/screeps.pid" 
logFile="/var/run/Screeps.log" 
workingDir="/var/local/screeps" 

command="start" 
nodeApp="/usr/local/bin/screeps" 
foreverApp="/usr/local/bin/forever" 

start() { 
    echo "Starting $nodeApp" 

    # Notice that we change the PATH because on reboot 
    # the PATH does not include the path to node. 
    # Launching forever with a full path 
    # does not work unless we set the PATH. 
    PATH=/usr/local/bin:$PATH 
    export NODE_ENV=production 

    su - screeps-daemon -c \ 
    `foreverApp start --workingDir $workingDir --pidFile $pidFile -l $logFile -a -d -c "$command" $nodeApp` 
    RETVAL=$? 
} 

restart() { 
    echo -n "Restarting $nodeApp" 
    $foreverApp restart $nodeApp 
    RETVAL=$? 
} 

stop() { 
    echo -n "Shutting down $nodeApp" 
    $foreverApp stop $nodeApp 
    RETVAL=$? 
} 

status() { 
    echo -n "Status $nodeApp" 
    $foreverApp list 
    RETVAL=$? 
} 

case "$1" in 
    start) 
     start 
     ;; 
    stop) 
     stop 
     ;; 
    status) 
     status 
     ;; 
    restart) 
    restart 
     ;; 
    *) 
     echo "Usage: {start|stop|status|restart}" 
     exit 1 
     ;; 
esac 
exit $RETVAL 

Aber ich erhalte den folgenden Fehler:

sudo /etc/init.d/screeps start                                 [email protected] 
Starting /usr/local/bin/screeps 
su: unrecognized option '--minUptime' 
Usage: su [options] [LOGIN] 

Options: 
    -c, --command COMMAND   pass COMMAND to the invoked shell 
    -h, --help     display this help message and exit 
    -, -l, --login    make the shell a login shell 
    -m, -p, 
    --preserve-environment  do not reset environment variables, and 
           keep the same shell 
    -s, --shell SHELL    use SHELL instead of the default in passwd 

Es ist wahrscheinlich etwas einfach mir ins Gesicht stareing aber ich kann nicht sehen es gerade jetzt.

Antwort

1

Es sieht so aus, als ob die Befehlszeile, die Sie für su verwenden, mit Backticks zitiert wird. Dies wird die Shell veranlassen, den Befehl auszuführen:

foreverApp start --workingDir $workingDir --pidFile $pidFile -l $logFile -a -d -c "$command" $nodeApp 

und hängen Sie dann, was auch immer, die an die su Kommandozeile zurückkehrt, nachdem „su - screeps-Daemon -c“.

Wahrscheinlich gibt es einen Fehler ausgeführt wird, dass foreverApp Befehl und die Hilfemeldung zurückkehrt (das ist, wo die „--minUptime“ wurde wahrscheinlich generiert)

Versuchen mit dem Apostroph zitiert 'anstelle des Graviszeichen `

0

fixiert ich das Problem, indem Sie Ihre Ausführung Skript ersetzt durch:

sudo - screeps-daemon -c \ 
    "$foreverApp start --workingDir $workingDir $nodeApp $command --password <my-password> --runners_cnt 4 --processors_cnt 4" 

Wo runners_cnt und processors_cnt sollten Sie widmen möchten viele Prozessorkerne je nach Hause gesetzt werden t er schreckt Server.

Nicht vergessen zu laufen sudo update-rc.d <scriptname> defaults

Verwandte Themen