Unicorn_init.sh cannot find app root on capistrano cold deploy
Posted
by
oFca
on Stack Overflow
See other posts from Stack Overflow
or by oFca
Published on 2012-11-02T22:56:55Z
Indexed on
2012/11/02
23:00 UTC
Read the original article
Hit count: 275
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 -c $APP_ROOT/config/unicorn.rb - E production"
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
© Stack Overflow or respective owner