在cap deploy:cold期间-找不到/etc/init.d/unicorn的命令 [英] During cap deploy:cold - command not found for /etc/init.d/unicorn

查看:136
本文介绍了在cap deploy:cold期间-找不到/etc/init.d/unicorn的命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我非常接近在Linode VPS上启动我的第一个Rails应用程序,但是在cap deploy:cold即将结束时继续收到奇怪的错误消息。我一直在关注railscasts 335,以便使用nginx,Unicorn,PostgreSQL,rbenv等将我的Rails应用程序部署到VPS(不幸的是,对于我而言,这是Windows计算机)。我托管在Linode Ubuntu 10.04 LTS Profile上。在部署即将结束时,我收到以下错误消息:

I'm very close to having my first rails app live up on Linode VPS, but keep on getting a strange error message near the end of cap deploy:cold. I've been following railscasts 335 to deploy my Rails app to a VPS using nginx, Unicorn, PostgreSQL, rbenv and more (unfortunately for me from a Windows machine). I'm hosting on Linode Ubuntu 10.04 LTS Profile. Near the end of the deploy I get this error message:

  * ←[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

当我转到服务器时,它会找到文件

When I go to the server, it locates the file

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

从deploy.rb

From 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

And from 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并尝试执行各种命令,执行时出现错误

I then head over to the VPS and try to execute the various commands and I get an error when executing the following:

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上获得回显$ 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

Here is what I get for echo $PATH on the VPS: /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仅显示在依赖项下,而不在规格下。

I have tried with both the unicorn gem under the production group and as part of the main gems, both have produced this same error message. When I open the Gemfile.lock in the current folder on the server Unicorn only shows up under the dependencies, not under the specs.

谢谢您的帮助!

推荐答案

好的这里有几个问题。

Alright, there was a couple of issues here.

1-我在本地计算机和服务器上使用了不同版本的捆绑器。

1 - I had different versions of bundler on my local machine and the server.

2-在Windows计算机上进行开发。我必须将独角兽gem放在我的gemfile中的一个生产组下,无论出于何种原因,结果gemfile.lock均未成功创建。如果有一个Mac好友,请拉我的代码,将独角兽移至gemfile的主要部分,然后将其捆绑安装。这创建了一个良好的Gemfile.lock,该服务器现在正在使用中。

2 - Developing on a Windows machine. I had to put the unicorn gem under a production group in my gemfile, and for whatever reason the gemfile.lock was not created successfully as a result. Had a buddy with a mac pull my code, move unicorn to the main section of the gemfile, and bundle installed it. This created a good Gemfile.lock which is in use now on the server.

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

Not sure if this will be helpful to others or not, quite the weird error.

这篇关于在cap deploy:cold期间-找不到/etc/init.d/unicorn的命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆