2013-04-24 25 views
1

我非常接近讓我的第一個rails應用程序在Linode VPS上運行起來,但在接近結束時仍然收到奇怪的錯誤消息帽子部署:冷。我一直在關注railscasts 335,通過nginx,Unicorn,PostgreSQL,rbenv等(不幸的是,我從Windows機器上)將Rails應用程序部署到VPS。我在Linode Ubuntu 10.04 LTS Profile上託管。附近部署結束時,我收到此錯誤信息:cap部署過程中:冷 - 找不到/etc/init.d/unicorn的命令

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

I t母雞頭以上的VPS,並嘗試執行各種命令和執行以下時,我得到一個錯誤:

[email protected]:~/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>' 

以下是我得到的回聲$ PATH的VPS: /家庭/部署/。 rbenv /墊片:/home/deployer/.rbenv/bin:在/ usr/local/sbin中:在/ usr/local/bin目錄:/ usr/sbin目錄:在/ usr/bin中:/ sbin目錄:/ bin中:在/ usr /遊戲:/ home/deployer/.rbenv/versions/1.9.3-p125/bin

我已經嘗試使用生產組下的獨角獸寶石,並且作爲主要寶石的一部分,兩者都產生了相同的錯誤消息。當我打開服務器上當前文件夾中的Gemfile.lock時,Unicorn只出現在依賴項下,而不是在規範下。

感謝您的任何幫助!

+1

你做了'cap deploy:setup',對吧? – scaryguy 2013-04-24 19:52:17

+0

是的,肯定跑帽部署:安裝前運行帽部署:冷 – 2013-04-24 21:29:47

回答

0

好的,這裏有幾個問題。

1 - 我的本地計算機和服務器上有不同版本的bundler。

2 - 在Windows機器上進行開發。我不得不將gentfile gem放在我的gemfile中的生產組下,並且由於某種原因gemfile.lock沒有成功創建。如果有一個帶MAC的夥伴拉我的代碼,將獨角獸移到gemfile的主要部分,然後捆綁安裝它。這創建了一個很好的Gemfile.lock,它現在在服務器上使用。

不知道這是否會對別人有幫助,相當奇怪的錯誤。

+0

得到完全相同的錯誤。但是我還沒有找到其他人推動代碼。 – cqcn1991 2013-09-22 11:30:16