在cap部署期间:冷却 - 找不到/etc/init.d/unicorn

时间:2013-04-24 18:35:30

标签: ruby-on-rails ruby ubuntu capistrano unicorn

我非常接近让我的第一个rails应用程序在Linode VPS上运行,但在封顶部署结束时继续收到一条奇怪的错误消息:冷。我一直在关注railscasts 335使用nginx,Unicorn,PostgreSQL,rbenv等将我的Rails应用程序部署到VPS(不幸的是我从Windows机器上)。我在Linode Ubuntu 10.04 LTS Profile上主持。在部署结束时,我收到以下错误消息:

  * ←[32m2013-04-24 13:08:13 executing `deploy:start'←[0m
  * ←[33mexecuting "sudo -p 'sudo password: ' /etc/init.d/unicorn_wheretoski start"←[0m
    servers: ["xxx.xx.xxx.242"]
    [xxx.xx.xxx.242] executing command
 ** [out :: xxx.xx.xxx.242]
 ** [out :: xxx.xx.xxx.242] sudo: /etc/init.d/unicorn_wheretoski: command not found
 ** [out :: xxx.xx.xxx.242]
    ←[2;37mcommand finished in 309ms←[0m
failed: "env PATH=$HOME/.rbenv/shims:$HOME/.rbenv/bin:$PATH sh -c 'sudo -p '\\''
sudo password: '\\'' /etc/init.d/unicorn_wheretoski start'" on xxx.xx.xxx.242

当我去服务器时,它找到了文件

:~/apps/wheretoski/current$ ls /etc/init.d/unicorn_wheretoski
/etc/init.d/unicorn_wheretoski

来自deploy.rb

namespace :deploy do
  %w[start stop restart].each do |command|
    desc "#{command} unicorn server"
    task command, roles: :app, except: {no_release: true} do
      sudo "/etc/init.d/unicorn_#{application} #{command}"
    end
  end 
......

来自unicorn_init.sh

#!/bin/sh
set -e

# Feel free to change any of the following variables for your app:
TIMEOUT=${TIMEOUT-60}
APP_ROOT=/home/deployer/apps/wheretoski/current
PID=$APP_ROOT/tmp/pids/unicorn.pid
CMD="cd $APP_ROOT; bundle exec unicorn -D -c $APP_ROOT/config/unicorn.rb -E production"
AS_USER=deployer
set -u

OLD_PIN="$PID.oldbin"

sig () {
  test -s "$PID" && kill -$1 `cat $PID`
}

oldsig () {
  test -s $OLD_PIN && kill -$1 `cat $OLD_PIN`
}

run () {
  if [ "$(id -un)" = "$AS_USER" ]; then
    eval $1
  else
    su -c "$1" - $AS_USER
  fi
}

case "$1" in
start)
  sig 0 && echo >&2 "Already running" && exit 0
  run "$CMD"
  ;;

然后我转到VPS并尝试执行各种命令,执行以下操作时出错:

deployer@li543-242:~/apps/wheretoski/current$ bundle exec unicorn -D -c $/home/apps/wheretoski/current/config/unicorn.rb -E production
/home/deployer/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/bundler-1.3.5/lib/bundler/rubygems_integration.rb:214:in `block in replace_gem': unicorn is not part of the bundle. Add it to Gemfile. (Gem::LoadError)
        from /home/deployer/.rbenv/versions/1.9.3-p125/bin/unicorn:22:in `<main>'

以下是我在VPS上获得echo $ PATH的内容:     /home/deployer/.rbenv/shims:/home/deployer/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin: /usr/games:/home/deployer/.rbenv/versions/1.9.3-p125/bin

我尝试过生产组下的独角兽宝石,作为主要宝石的一部分,两者都产生了同样的错误信息。当我在服务器上的当前文件夹中打开Gemfile.lock时,Unicorn只显示在依赖项下,而不是在规范下。

感谢您的帮助!!

1 个答案:

答案 0 :(得分:0)

好吧,这里有几个问题。

1 - 我的本地计算机和服务器上有不同版本的bundler。

2 - 在Windows机器上开发。我不得不将unicorn gem放在我的gemfile中的一个生产组下,无论出于何种原因,gemfile.lock都没有成功创建。如果一个带有mac的好友拉我的代码,将独角兽移动到gemfile的主要部分,并捆绑安装它。这创建了一个很好的Gemfile.lock,它现在在服务器上使用。

不确定这对其他人是否有帮助,非常奇怪的错误。

相关问题