1

私は約 500 個のものを使用しているので注意が必要ですが、10 個のノード (異なるサーバー) に相当するものを処理するようにセットアップされた Vagrant ボックスがあります。ローカルですべてを行う 1 つのボックスであり、本番環境とステージング環境で別のサーバーに分割します。

現在、Chef セットアップ経由で graylog2 に rbenv を使用させることができません。rbenv をインストールし、rbenv シムを使用して bundle install を実行し、gem をすべてインストールしました。しかし、実際に実行中のアプリケーションは次のようにエラーになっています。

バンドラーに関する旅客エラー

シェフのレシピは次のようになります。

# Install required APT packages
package "build-essential"
package "postfix"

include_recipe "rbenv::default"
include_recipe "rbenv::ruby_build"

use_ruby_version = "1.9.3-p327"
rbenv_ruby use_ruby_version

# Install gem dependencies
%w{ bundler rake }.each do |g|
  rbenv_gem "#{g}" do
    ruby_version "#{use_ruby_version}"
  end
end

# Create the release directory
directory "#{node.graylog2.basedir}/rel" do
  mode 0755
  recursive true
end

# Download the desired version of Graylog2 web interface from GitHub
remote_file "download_web_interface" do
  path "#{node.graylog2.basedir}/rel/graylog2-web-interface-#{node.graylog2.web_interface.version}.tar.gz"
  source "https://github.com/downloads/Graylog2/graylog2-web-interface/graylog2-web-interface-#{node.graylog2.web_interface.version}.tar.gz"
  action :create_if_missing
end

# Unpack the desired version of Graylog2 web interface
execute "tar zxf graylog2-web-interface-#{node.graylog2.web_interface.version}.tar.gz" do
  cwd "#{node.graylog2.basedir}/rel"
  creates "#{node.graylog2.basedir}/rel/graylog2-web-interface-#{node.graylog2.web_interface.version}/build_date"
  action :nothing
  subscribes :run, resources(:remote_file => "download_web_interface"), :immediately
end

# Link to the desired Graylog2 web interface version
link "#{node.graylog2.basedir}/web" do
  to "#{node.graylog2.basedir}/rel/graylog2-web-interface-#{node.graylog2.web_interface.version}"
end

# Perform bundle install on the newly-installed Graylog2 web interface version
bash "bundle install" do
  cwd "#{node.graylog2.basedir}/web"
  code "rbenv local #{use_ruby_version} && source /etc/profile.d/rbenv.sh && bundle install"
  subscribes :run, resources(:link => "#{node.graylog2.basedir}/web"), :immediately
end

# Create mongoid.yml
template "#{node.graylog2.basedir}/web/config/mongoid.yml" do
  mode 0644
end

# Create general.yml
template "#{node.graylog2.basedir}/web/config/general.yml" do
  owner "nobody"
  group "nogroup"
  mode 0644
end

# Chown the Graylog2 directory to nobody/nogroup to allow web servers to serve it
execute "sudo chown -R nobody:nogroup graylog2-web-interface-#{node.graylog2.web_interface.version}" do
  cwd "#{node.graylog2.basedir}/rel"
  not_if do
    File.stat("#{node.graylog2.basedir}/rel/graylog2-web-interface-#{node.graylog2.web_interface.version}").uid == 65534
  end
  action :nothing
  subscribes :run, resources(:bash => "bundle install"), :immediately
end

# Stream message rake tasks
cron "Graylog2 send stream alarms" do
  minute node[:graylog2][:stream_alarms_cron_minute]
  action node[:graylog2][:send_stream_alarms] ? :create : :delete
  command "cd #{node[:graylog2][:basedir]}/web && RAILS_ENV=production bundle exec rake streamalarms:send"
end

cron "Graylog2 send stream subscriptions" do
  minute node[:graylog2][:stream_subscriptions_cron_minute]
  action node[:graylog2][:send_stream_subscriptions] ? :create : :delete
  command "cd #{node[:graylog2][:basedir]}/web && RAILS_ENV=production bundle exec rake subscriptions:send"
end

これは元のものとほとんど同じですがrbenv localbash "bundle install"chef リソースで使用する違いがあります。

それで...それがインストールされて実行されている場合...実行時にRailsに上記の宝石について知らせるにはどうすればよいでしょうか? それはスクリーンショットの問題でもありますか?何が起きていて、どうすれば修正できますか?

4

2 に答える 2

2

Graylog2 の開始方法が、最初に rbenv を適切に起動していない可能性があります。これを行う最も簡単な方法は、rbenv wiki ページによると、インストールを binstubs にバンドルすることです。したがって、バンドルのインストール行を次のように変更します。

bundle install --deployment --binstubs

サーバーの起動に使用するコマンドが含まれていませんでした。(Apache を使用していますか? Unicorn を使用していますか?) Unicorn または Thin またはその他のサーバーをオンデマンドで簡単に起動できる場合、問題はほぼ解決されます。rbenv ラッパーからアプリを起動するだけで、適切な rbenv で実行されます。

/path/to/my/current/bin/unicorn

于 2013-06-13T15:03:20.233 に答える
0

以下を追加しました。

LoadModule passenger_module /opt/rbenv/versions/<%= node[:graylog2][:ruby_version] %>/lib/ruby/gems/1.9.1/gems/passenger-4.0.5/libout/apache2/mod_passenger.so
PassengerRoot /opt/rbenv/versions/<%= node[:graylog2][:ruby_version] %>/lib/ruby/gems/1.9.1/gems/passenger-4.0.5
PassengerDefaultRuby /opt/rbenv/versions/<%= node[:graylog2][:ruby_version] %>/bin/ruby

私は、graylog2 クックブックにプル リクエストを送信しています。このクックブックは、これらすべてをすぐに処理します。うまくいけば、承認されることを願っています。

于 2013-06-13T17:50:48.117 に答える