Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🌌 Clusterize #2749

Draft
wants to merge 20 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 18 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@ EXPOSE 3000
CMD rake jetty:clean && rake jetty:config && rake jetty:start && bundle exec rake db:migrate RAILS_ENV=development && bundle exec rails s -b 0.0.0.0

FROM base as production
ENV RAILS_ENV=production
ENV AAPB_LOG=log/build.log

RUN apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*


COPY . .

RUN rake jetty:clean && rake jetty:config
RUN bundle exec rake assets:precompile

RUN RAILS_ENV=production bundle exec rake db:migrate

CMD rake jetty:start && bundle exec rake db:migrate RAILS_ENV=development && bundle exec rails s -b 0.0.0.0
CMD rails s -b 0.0.0.0
2 changes: 1 addition & 1 deletion app/controllers/oai_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def index
@response_date = Time.now.strftime('%FT%T')

@records =
RSolr.connect(url: 'http://localhost:8983/solr/')
RSolr.connect(url: config.solr_url)
.get('select', params: {
'q' => 'access_types:"' + PBCorePresenter::PUBLIC_ACCESS + '"',
'fl' => 'id,timestamp,xml',
Expand Down
2 changes: 1 addition & 1 deletion app/models/pb_core_presenter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ def playlist_order
end
def playlist_map
@playlist_map ||= begin
response = RSolr.connect(url: 'http://localhost:8983/solr/').get('select', params:
response = RSolr.connect(url: config.solr_url).get('select', params:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrharpo where does the config method come from here?

{
'fl' => 'playlist_order,id',
'fq' => "playlist_group:#{playlist_group}",
Expand Down
12 changes: 6 additions & 6 deletions config/blacklight.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
# each environment can have a jetty_path with absolute or relative
# (to app root) path to a jetty/solr install. This is used
# by the rake tasks that start up solr automatically for testing
# and by rake solr:marc:index.
# and by rake solr:marc:index.
#
# jetty_path is not used by a running Blacklight application
# at all. In general you do NOT need to deploy solr in Jetty, you can deploy it
# however you want.
# however you want.
# jetty_path is only required for rake tasks that need to know
# how to start up solr, generally for automated testing.
# how to start up solr, generally for automated testing.

development:
url: http://127.0.0.1:8983/solr/blacklight-core
url: http://127.0.0.1:8983/solr/
test:
url: http://127.0.0.1:8983/solr/blacklight-core
url: http://127.0.0.1:8983/solr/
# TODO: Get separate dev and test cores, and change this back to 8888. bug #1
production:
url: http://127.0.0.1:8983/solr/blacklight-core
url: <%= ENV['SOLR_URL'] || 'http://127.0.0.1:8983/solr/' %>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think Blacklight might be expecting the core name (blacklight-core) as part of the URL, isn't it?

2 changes: 1 addition & 1 deletion config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
# config.log_tags = [ :subdomain, :uuid ]

# Only keep up to 10 log files of ~ 1MB each.
config.logger = ActiveSupport::Logger.new('/var/www/aapb/current/log/production.log', 10, 1.megabytes)
config.logger = ActiveSupport::Logger.new(ENV['AAPB_LOG'] || '/var/www/aapb/current/log/production.log', 10, 1.megabytes)

# Use a different cache store in production.
# config.cache_store = :mem_cache_store
Expand Down
3 changes: 2 additions & 1 deletion lib/solr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ class Solr
def initialize
environment = ENV['RAILS_ENV'] || DEFAULT
conf = YAML.load_file(Rails.root + 'config/blacklight.yml')
@connect = RSolr.connect(url: conf[environment]['url'])
solr_url = ENV['SOLR_URL'] || conf[environment]['url']
@connect = RSolr.connect(url: solr_url + 'blacklight-core')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(see also above comment)

Blacklight gem may be expecting the core name to be a part of the configured URL, so we may run into issues by removing it from blacklight.yml and adding it back here.

end

attr_reader :connect
Expand Down
2 changes: 1 addition & 1 deletion scripts/lib/downloader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def process_query(query)
q = QueryMaker.translate(query)
$LOG.info("Query solr for #{query}")

@options[:ids] = RSolr.connect(url: 'http://localhost:8983/solr/')
@options[:ids] = RSolr.connect(url: config.solr_url)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(see other related comments)

we're leaving the core name off here, but adding it when connecting to Solr in lib/solr.rb.

.get('select',
params: { q: q, fl: 'id', rows: MAX_ROWS }
)['response']['docs'].map { |doc| doc['id'] }
Expand Down
Loading