在answer here之后,我有以下部署:
$ ls -alh /etc/init.d
# unicorn_init_include.sh -> /home/deployer/abc/current/config/unicorn_init_include.sh
# unicorn_abc -> /home/deployer/abc/current/config/unicorn_init_staging.sh
# /home/deployer/abc/current/config/unicorn_init_staging.sh
#!/bin/sh
RAILS_ENV="staging"
export RAILS_ENV
unicorn_init_include.sh
# /home/deployer/abc/current/config/unicorn_init_include.sh
#!/bin/sh
set -e
TIMEOUT=${TIMEOUT-60}
APP_ROOT=/home/deployer/abc/current
CMD="cd $APP_ROOT; bundle exec unicorn -D -c $APP_ROOT/config/unicorn.rb -E $RAILS_ENV"
当我使用Capistrano deploy:setup
时,你会注意到它都是符号链接的:
executing "sudo -p 'sudo password: ' ln -nfs /home/deployer/abc/current/config/unicorn_init_staging.sh /etc/init.d/unicorn_abc"
servers: ["192.168.33.10"]
[192.168.33.10] executing command
[out :: 192.168.33.10]
command finished in 611ms
executing "sudo -p 'sudo password: ' ln -nfs /home/deployer/abc/current/config/unicorn_init_include.sh /etc/init.d/unicorn_init_include.sh"
servers: ["192.168.33.10"]
[192.168.33.10] executing command
[out :: 192.168.33.10]
command finished in 602ms
但是当卡皮斯特拉诺试图解雇命令时:
** [out :: 192.168.33.10] /etc/init.d/unicorn_abc: 4: /etc/init.d/unicorn_abc:
** [out :: 192.168.33.10] unicorn_init_include.sh: not found
我尝试将unicorn_init_include.sh
中的unicorn_init_staging.sh
更改为./unicorn_init_include.sh
,将unicorn_abc
符号链接到/etc/init.d/
(如上所示),但它没有'工作。
我做错了什么?
答案 0 :(得分:0)
尝试完整路径
变化
export RAILS_ENV
unicorn_init_include.sh
到
export RAILS_ENV
/etc/init.d/unicorn_init_include.sh
答案 1 :(得分:0)
错误发生在你的unicorn_init_staging.sh第4行。调用unicorn_abc时,它不是从工作目录/ home / deployer / abc / current / config调用,而是在其他地方调用,比如/etc/init.d。所以它找不到你的unicorn_init_include.sh。
您可以通过添加
进行问题排查echo 'pwd'
到staging.sh文件
可能需要将暂存文件更改为(未测试)
#!/bin/bash
RAILS_ENV="staging"
export RAILS_ENV
`dirname ${BASH_SOURCE[0]}`/unicorn_init_include.sh