Skip to content

Commit

Permalink
[SEARCH] Added a template for Elasticsearch application initializer
Browse files Browse the repository at this point in the history
The `elasticsearch_url` variable is set in the "secret/rubygems" data bag,
similar to setting PostgreSQL host, etc.

Alternatively, an environment variable `ELASTICSEARCH_URL` could be used.

Related: rubygems/rubygems.org#455
  • Loading branch information
karmi committed May 10, 2013
1 parent 02d8518 commit 8e0e3dd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
14 changes: 12 additions & 2 deletions chef/site-cookbooks/rubygems/recipes/rails.rb
Expand Up @@ -86,7 +86,7 @@
notifies :restart, "service[rg_delayed_job]"
end

# logrotate for application
# Logrotate for application
template "/etc/logrotate.d/#{app_env}" do
source "logrotate-application.erb"
owner "root"
Expand All @@ -96,7 +96,7 @@
variables(service_name: app_env, rails_root: rails_root)
end

# logrotate for application
# Rails initializer for secret
template "#{node["application"]["rails_root"]}/current/config/secret.rb" do
source "secret.rb.erb"
owner "deploy"
Expand All @@ -106,6 +106,16 @@
variables(s3_key: s3_key, s3_secret: s3_secret, secret_token: secret_token, bundler_token: bundler_token, bundler_api_url: bundler_api_url, new_relic_license_key: new_relic_license_key, new_relic_app_name: new_relic_app_name)
end

# Rails initializer for Elasticsearch
template "#{node["application"]["rails_root"]}/current/config/initializers/tire.rb" do
source "tire.rb.erb"
owner "deploy"
group "deploy"
mode "0600"
action :create
variables(elasticsearch_url: rubygems_settings["elasticsearch_url"])
end

# Simplest thing that works: setup the worker; logs will be in the
# rails_root/shared/log/rg_delayed_job
directory "#{node['application']['rails_root']}/shared/log/rg_delayed_job" do
Expand Down
3 changes: 3 additions & 0 deletions chef/site-cookbooks/rubygems/templates/default/tire.rb.erb
@@ -0,0 +1,3 @@
Tire.configure do
url "<%= @elasticsearch_url %>"
end

0 comments on commit 8e0e3dd

Please sign in to comment.