ruby-on-rails - 在上限部署期间 :cold - command not found for/etc/init. d/unicorn

标签 ruby-on-rails ruby ubuntu capistrano unicorn

我非常接近让我的第一个 Rails 应用程序在 Linode VPS 上运行,但在 cap deploy:cold 快结束时不断收到一条奇怪的错误消息。我一直在关注 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

从部署.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

我已经尝试过使用生产组下的 unicorn gem 和作为主要 gem 的一部分,两者都产生了相同的错误消息。当我打开服务器上当前文件夹中的 Gemfile.lock 时,Unicorn 仅显示在依赖项下,而不是规范下。

谢谢你的帮助!!

最佳答案

好吧,这里有几个问题。

1 - 我的本地机器和服务器上有不同版本的捆绑程序。

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

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

关于ruby-on-rails - 在上限部署期间 :cold - command not found for/etc/init. d/unicorn,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16199654/

相关文章:

ruby-on-rails - Rails 帮助查找方法

ruby-on-rails - 如何在 Ruby on Rails 中的数据库对象之前获取 100 个项目

ruby-on-rails - 在 Rails 应用程序中升级 Ruby 版本和 gemsets 的安全方法

ruby - 在 MySQL2 gem 中使用准备好的语句?

arrays - 圆形阵列切片

ruby - Ruby 中的私有(private)/ protected block ?

linux - 如何查找非官方安装的软件包?

ruby-on-rails - Billing.subscription.renewed webhook 未被触发

linux - 使用 lftp 比较远程目录而不执行传输

c++ - 如何从源代码安装 boost 获得与从存储库安装 boost 相同的结果?