2010-11-23 12 views
4

私は自分のWebサーバー上でサービスとしてthinを実行しようとしています。 「sudoの薄いインストール」を実行した後に、薄いサービスとしてthinを使用してRailsアプリケーションを実行しています

#!/bin/sh 
DAEMON=/usr/local/lib/ruby/gems/1.9.1/bin/thin 
SCRIPT_NAME=/etc/init.d/thin 
CONFIG_PATH=/etc/thin 

# Exit if the package is not installed 
[ -x "$DAEMON" ] || exit 0 

case "$1" in 
    start) 
     $DAEMON start --all $CONFIG_PATH 
     ;; 
    stop) 
     $DAEMON stop --all $CONFIG_PATH 
     ;; 
    restart) 
     $DAEMON restart --all $CONFIG_PATH 
     ;; 
    *) 
     echo "Usage: $SCRIPT_NAME {start|stop|restart}" >&2 
     exit 3 
     ;; 
esac 

を/etc/init.d/thinで次のファイルを薄くサービスが開始されると、次は

thin start --all /etc/thin
走っている。これは、定義のYAML設定ファイルのすべてをスキャンしますを作成しました定義された各アプリに対して細い方法これは動作しません。

私は私のログに表示さ

/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.0/lib/bundler/runtime.rb:27:in `block in setup': You have already activated eventmachine 0.12.6, but your Gemfile requires eventmachine 0.12.11. Consider using bundle exec. (Gem::LoadError) 
    from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.0/lib/bundler/spec_set.rb:12:in `block in each' 
    from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.0/lib/bundler/spec_set.rb:12:in `each' 
    from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.0/lib/bundler/spec_set.rb:12:in `each' 
    from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.0/lib/bundler/runtime.rb:17:in `setup' 
    from /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.0/lib/bundler.rb:100:in `setup' 
    from /srv/app/current/config/boot.rb:8:in `<top (required)>' 
    from <internal:lib/rubygems/custom_require>:29:in `require' 
    from <internal:lib/rubygems/custom_require>:29:in `require' 
    from /srv/app/current/config/application.rb:1:in `<top (required)>' 
    from <internal:lib/rubygems/custom_require>:29:in `require' 
    from <internal:lib/rubygems/custom_require>:29:in `require' 
    from /srv/app/current/config/environment.rb:2:in `<top (required)>' 
    from <internal:lib/rubygems/custom_require>:29:in `require' 
    from <internal:lib/rubygems/custom_require>:29:in `require' 
    from /srv/app/current/config.ru:3:in `block in <main>' 
    from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.2.1/lib/rack/builder.rb:46:in `instance_eval' 
    from /usr/local/lib/ruby/gems/1.9.1/gems/rack-1.2.1/lib/rack/builder.rb:46:in `initialize' 
    from /srv/app/current/config.ru:1:in `new' 
    from /srv/app/current/config.ru:1:in `<main>' 
    from /usr/local/lib/ruby/gems/1.9.1/gems/thin-1.2.7/lib/rack/adapter/loader.rb:36:in `eval' 
    from /usr/local/lib/ruby/gems/1.9.1/gems/thin-1.2.7/lib/rack/adapter/loader.rb:36:in `load' 
    from /usr/local/lib/ruby/gems/1.9.1/gems/thin-1.2.7/lib/rack/adapter/loader.rb:45:in `for' 
    from /usr/local/lib/ruby/gems/1.9.1/gems/thin-1.2.7/lib/thin/controllers/controller.rb:163:in `load_adapter' 
    from /usr/local/lib/ruby/gems/1.9.1/gems/thin-1.2.7/lib/thin/controllers/controller.rb:67:in `start' 
    from /usr/local/lib/ruby/gems/1.9.1/gems/thin-1.2.7/lib/thin/runner.rb:177:in `run_command' 
    from /usr/local/lib/ruby/gems/1.9.1/gems/thin-1.2.7/lib/thin/runner.rb:143:in `run!' 
    from /usr/local/lib/ruby/gems/1.9.1/gems/thin-1.2.7/bin/thin:6:in `<top (required)>' 
    from /usr/local/lib/ruby/gems/1.9.1/bin/thin:19:in `load' 
    from /usr/local/lib/ruby/gems/1.9.1/bin/thin:19:in `<main>' 

カピストラーノを展開すると、私は$ APP_PATH /共有/バンドルディレクトリの中に私のバンドルをキャッシュしています。

cd $APP_PATH/current; bundle exec thin start -d -C /etc/thin/app_x.yml 

が、それは仕方薄いない:そう、薄いが薄くサービスとしてインストールされていない宝石文句を言う理由が説明すると、これは、作業を行う$ APP_PATH /共有/バンドル

には見えません。 /etc/init.d/thinのサービスファイルが動作します。私は自分自身を書くことができると思う。私はすでに解決されている問題を解決したくありません。

+0

エラーは、インストールされていない宝石に関するものではありません。問題は、異なるバージョンのアクティブマシンが2回アクティブ化されていることです。これは、実行中にバンドルexecを実行することです。 –

+0

VP、はい。 thin start --allは各アプリケーションの既存のバンドルキャッシュを認識していないようです。 –

+0

私は、私が誇りに思っていないものを持っています。 https://gist.github.com/712690 –

答えて

1

私はこれを思いついたのですが、ディレクトリから設定ファイルを読み込むときにシンの "--all"オプションを利用していないので、これが最善の解決策であるとは思われません。代わりに、私は起動/停止/再起動のための特定のコマンドを与える各アプリケーションのためにシンサービスを開始/停止/再起動するファイルを変更しました。私はこのコマンドを改善することができると確信していますが、今のところそれは私の必要に応えます。

#!/bin/sh 

# This is a pretty bad, but effective workaround for starting thin as a service per application. 

DAEMON=/usr/local/lib/ruby/gems/1.9.1/bin/thin 
# DAEMON=/usr/local/bin/bundler thin 
SCRIPT_NAME=/etc/init.d/thin 
CONFIG_PATH=/etc/thin 

# Exit if the package is not installed 
[ -x "$DAEMON" ] || exit 0 

case "$1" in 
    start) 
    cd /srv/hub/current && bundle exec thin start -d -C /etc/thin/hub.yml 
    ;; 
    stop) 
    cd /srv/hub/current && bundle exec thin stop -d -C /etc/thin/hub.yml 
    ;; 
    restart) 
    cd /srv/hub/current && bundle exec thin restart -d -C /etc/thin/hub.yml 
    ;; 
    *) 
    echo "Usage: $SCRIPT_NAME {start|stop|restart}" >&2 
    exit 3 
    ;; 
esac 
関連する問題