I am deploying Rails app and upon running

cap deploy:cold

I get the error saying

  * 2012-11-02 23:53:26 executing `deploy:migrate'
  * executing "cd /home/mr_deployer/apps/prjct_mngr/releases/20121102225224 && bundle exec rake RAILS_ENV=production  db:migrate"
    servers: ["xxxxxxxxxx"]
    [xxxxxxxxxx] executing command
    command finished in 7464ms
  * 2012-11-02 23:53:34 executing `deploy:start'
  * executing "/etc/init.d/unicorn_prjct_mngr start"
    servers: ["xxxxxxxxxx"]
    [xxxxxxxxxx] executing command
 ** [out :: xxxxxxxxxx] /etc/init.d/unicorn_prjct_mngr: 33: cd: can't cd to /home/mr_deployer/apps/prjct_mngr/current;
    command finished in 694ms
failed: "rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell '1.9.3-p125@prjct_mngr' -c '/etc/init.d/unicorn_prjct_mngr start'" on xxxxxxxxxx

but my app root is there! Why can't it find it? Here's part of my unicorn_init.sh file :

  1 #!/bin/sh
  2 set -e
  3 # Example init script, this can be used with nginx, too,
  4 # since nginx and unicorn accept the same signals
  5 
  6 # Feel free to change any of the following variables for your app:
  7 TIMEOUT=${TIMEOUT-60}
  8 APP_ROOT=/home/mr_deployer/apps/prjct_mngr/current
  9 PID=$APP_ROOT/tmp/pids/unicorn.pid
 10 CMD="cd $APP_ROOT; bundle exec unicorn -D -E production -c $APP_ROOT/config/unicorn.rb"
 11 # INIT_CONF=$APP_ROOT/config/init.conf
 12 AS_USER=mr_deployer
 13 action="$1"
 14 set -u
 15 
 16 # test -f "$INIT_CONF" && . $INIT_CONF
 17 
 18 old_pid="$PID.oldbin"
 19 
 20 cd $APP_ROOT || exit 1
 21 
 22 sig () {
 23   test -s "$PID" && kill -$1 `cat $PID`
 24 }
 25 
 26 oldsig () {
 27   test -s $old_pid && kill -$1 `cat $old_pid`
 28 }
 29 case $action in
 30 
 31 start)
 32   sig 0 && echo >&2 "Already running" && exit 0
 33   $CMD
 34   ;;
 35 
 36 stop)
 37   sig QUIT && exit 0
 38   echo >&2 "Not running"
 39   ;;
 40 
 41 force-stop)
 42   sig TERM && exit 0
 43   echo >&2 "Not running"
 44   ;;
 45 
 46 restart|reload)
 47   sig HUP && echo reloaded OK && exit 0
 48   echo >&2 "Couldn't reload, starting '$CMD' instead"
 49   $CMD
 50   ;;
 51 
 52 upgrade)
 53   if sig USR2 && sleep 2 && sig 0 && oldsig QUIT
 54   then
 55     n=$TIMEOUT
 56     while test -s $old_pid && test $n -ge 0
 57     do
 58       printf '.' && sleep 1 && n=$(( $n - 1 ))
 59     done
 60     echo
 61 
 62     if test $n -lt 0 && test -s $old_pid
 63     then
 64       echo >&2 "$old_pid still exists after $TIMEOUT seconds"
 65       exit 1
 66     fi
 67     exit 0
 68   fi
 69   echo >&2 "Couldn't upgrade, starting '$CMD' instead"
 70   $CMD
 71   ;;
 72 
 73 reopen-logs)
 74 sig USR1
 75 ;;
 76 
 77 *)
 78   echo >&2 "Usage: $0 <start|stop|restart|upgrade|force-stop|reopen-logs>"
 79   exit 1
 80   ;;
 81 esac

---------------------------------------

UPDATE:

I ran the command it complaints about (below)

cd /home/mr_deployer/apps/prjct_mngr/current; bundle exec unicorn -D -E production -c /home/mr_deployer/apps/prjct_mngr/current/config/unicorn.rb

on my VPS and it worked! It just doesnt work when I cap deploy:cold. Why is that?

share|improve this question

Are the access rights correctly set? You are setting the AS_USER variable, but do you use that user to start the server?

share|improve this answer
    
in my deploy.rb, I have line set :user, "mr_deployer", so yeah, I think so. I also have set :use_sudo, false. should I change to true? – oFca Nov 2 '12 at 23:02
    
btw, I updated the question :) – oFca Nov 3 '12 at 0:21
    
I think your init script is executed as the wrong user somehow. It doesn't complain about the folder not existing, it complains about not being able to access it. – Femaref Nov 3 '12 at 0:31

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.