2010-11-23 3 views
4

내 웹 서버에서 서비스로 씬을 실행하려고합니다. 실행 한 후, 얇은 얇은 서비스가 시작되면얇은 서비스로 레일스 앱 실행

#!/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에 다음 파일을 생성 "얇은 sudo를 설치"를

thin start --all /etc/thin
실행되어 다음이 YAML 설정 파일의 모든 정의 스캔 정의 된 각 앱에 대해 씬 실행 방법. 이것은 작동하지 않습니다. 내 로그에서 볼

:

카피 스트라 노, 내가 $ APP_PATH/공유/번들 디렉토리에 내 번들을 캐싱하고 배포
/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>' 

; 하지만 그 얇은 방법

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

되지 않습니다 : 얇은 얇은 서비스가 $의 APP_PATH/공유/번들

에 보이지 않는 설치되지 않은 보석에 대해 불평 왜 그렇게이이 작업 않습니다 설명 /etc/init.d/thin에있는 서비스 파일. 나는 내 자신을 쓸 수 있다고 생각한다. 나는 이미 해결 된 문제를 해결하고 싶지 않습니다.

+0

오류가 설치되지 않은 보석에 관한 것이 아니라는 점에 유의하십시오. 문제는 다른 버전에 대해 두 번 활성화되는 activemachine에 관한 것이며, 제안 된 수정은 여러분이하고있는 것처럼 번들 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