it-swarm.com.de

Erhalten von "nicht in der Lage, // zu bündeln (keine solche Datei oder kein solches Verzeichnis)", obwohl die Datei existiert

Ich hoffe, dies ist nur ein Problem, da ich nicht verstehe, wie die Variable $ PATH funktioniert. Ich benutze Ubuntu 14.04. Ich versuche, Rails über einen Unicorn-Server auszuführen. Ich habe die folgende Konfiguration für meinen Unicorn-Server

# Change parameters below to appropriate values and set CONFIGURED to yes.
CONFIGURED=yes

# Default timeout until child process is killed during server upgrade,
# it has *no* relation to option "timeout" in server's config.rb.
TIMEOUT=60

# Path to your web application, sh'ld be also set in server's config.rb,
# option "working_directory". Rack's config.ru is located here.
APP_ROOT=/home/Rails/mydomain

# Server's config.rb, it's not a rack's config.ru
CONFIG_RB=/etc/Unicorn.conf

# Where to store PID, sh'ld be also set in server's config.rb, option "pid".
PID=/var/run/Unicorn.pid
Rails_ENV="production"
Unicorn_OPTS="-D -c $CONFIG_RB -E $Rails_ENV"

export GEM_HOME=/home/Rails/.gem
export GEM_PATH=$GEM_HOME/Ruby/2.4.0
PATH=$GEM_HOME/bin:/usr/local/rvm/rubies/Ruby-2.4.0/bin/:/usr/local/sbin:/usr/bin:/bin:/sbin:/usr/local/rvm/bin
which bundle
cd $APP_ROOT
DAEMON="bundle exec $GEM_PATH/bin/Unicorn"

Wenn ich meinen Unicorn-Server starte, wird dieser Fehler angezeigt

[email protected]:~$ Sudo service Unicorn restart
/home/Rails/.gem/bin/bundle
 * Restarting Unicorn web server Unicorn 

 start-stop-daemon: unable to stat //bundle (No such file or directory)

Warum beschwert es sich über "bundle (No such file or directory)", wenn ich das gerade in der "which" -Anweisung ausgedruckt habe? Offensichtlich existiert das Dateibündel. Ich habe meine /etc/init.d/Unicorn-Datei unten eingefügt, wenn es nützlich ist.

#!/bin/sh
### BEGIN INIT INFO
# Provides:          Unicorn
# Required-Start:    $local_fs $remote_fs
# Required-Stop:     $local_fs $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Unicorn initscript
# Description:       Unicorn
### END INIT INFO

set -e
NAME=Unicorn
DESC="Unicorn web server"

. /lib/lsb/init-functions

if [ -f /etc/default/Unicorn ]; then
  . /etc/default/Unicorn
fi

PID=${PID-/run/Unicorn.pid}

run_by_init() {
    ([ "${previous-}" ] && [ "${runlevel-}" ]) || [ "${runlevel-}" = S ]
}

exit_with_message() {
  if ! run_by_init; then
    log_action_msg "$1 Not starting."
  fi
  exit 0
}

check_config() {
  if [ $CONFIGURED != "yes" ]; then
    exit_with_message "Unicorn is not configured (see /etc/default/Unicorn)."
  fi
}

check_app_root() {
  if ! [ -d $APP_ROOT ]; then
    exit_with_message "Application directory $APP_ROOT is not exist."
  fi
}

set -u

case "$1" in
  start) 
        check_config
        check_app_root

        log_daemon_msg "Starting $DESC" $NAME || true
        if start-stop-daemon --start --quiet --oknodo --pidfile $PID --exec $DAEMON -- $Unicorn_OPTS; then
          log_end_msg 0 || true
        else
          log_end_msg 1 || true
        fi
        ;;
  stop)
        log_daemon_msg "Stopping $DESC" $NAME || true
        if start-stop-daemon --stop --signal QUIT --quiet --oknodo --pidfile $PID; then
          log_end_msg 0 || true
        else
          log_end_msg 1 || true
        fi
        ;;
  force-stop)
        log_daemon_msg "Forcing stop of $DESC" $NAME || true
        if start-stop-daemon --stop --quiet --oknodo --pidfile $PID; then
          log_end_msg 0 || true
        else
          log_end_msg 1 || true
        fi
        ;;
  restart|force-reload)
        log_daemon_msg "Restarting $DESC" $NAME || true
        start-stop-daemon --stop --quiet --oknodo --pidfile $PID
        sleep 1
        if start-stop-daemon --start --quiet --oknodo --pidfile $PID --exec $DAEMON -- $Unicorn_OPTS; then
          log_end_msg 0 || true
        else
          log_end_msg 1 || true
        fi
        ;;
  reload)
        log_daemon_msg "Reloading $DESC" $NAME || true
        if start-stop-daemon --stop --signal HUP --quiet --oknodo --pidfile $PID; then
          log_end_msg 0 || true
        else
          log_end_msg 1 || true
        fi
        ;;
  reopen-logs)
        log_daemon_msg "Relopening log files of $DESC" $NAME || true
        if start-stop-daemon --stop --signal USR1 --quiet --oknodo --pidfile $PID; then
          log_end_msg 0 || true
        else
          log_end_msg 1 || true
        fi
        ;;
  status)
        status_of_proc -p $PID $DAEMON $NAME && exit 0 || exit $?
        ;;
  *)
        log_action_msg "Usage: $0 <start|stop|restart|force-reload|reload|force-stop|reopen-logs|status>" || true
        exit 1
        ;;
esac
2
Dave

Der Grund dafür ist, dass der an start-stop-daemon übergebene Ausführungspfad vollständig qualifiziert sein muss. Das Update ist zu setzen

DAEMON="/path/to/bundle exec $GEM_PATH/bin/Unicorn"

Sie können dies anhand dieses einfachen Beispiels testen

$ Sudo start-stop-daemon --start --oknodo --user lathiat --pidfile /tmp/pid1 --exec sleep 60 -- 
[Sudo] password for lathiat: 
start-stop-daemon: unable to stat //sleep (No such file or directory)

$ Sudo start-stop-daemon --start --oknodo --user lathiat --pidfile /tmp/pid1 --exec /bin/sleep 60 -- 
1
Trent Lloyd