File tree Expand file tree Collapse file tree 4 files changed +21
-11
lines changed
Expand file tree Collapse file tree 4 files changed +21
-11
lines changed Original file line number Diff line number Diff line change @@ -256,8 +256,8 @@ services:
256256 environment :
257257 - OL_CONFIG=/olsystem/etc/openlibrary.yml
258258 - OL_URL=https://openlibrary.org/
259- - EXTRA_OPTS=--solr-url http://ol-solr0:8984/solr/openlibrary
260- --no-solr-next
259+ - OL_SOLR_BASE_URL= http://ol-solr0:8984/solr/openlibrary
260+ - EXTRA_OPTS= --no-solr-next
261261 volumes :
262262 - ../olsystem:/olsystem
263263 logging :
@@ -276,9 +276,9 @@ services:
276276 environment :
277277 - OL_CONFIG=/olsystem/etc/openlibrary.yml
278278 - OL_URL=https://openlibrary.org/
279+ - OL_SOLR_BASE_URL=http://ol-solr1:8984/solr/openlibrary
279280 - STATE_FILE=solr-next-update.offset
280- - EXTRA_OPTS=--solr-url http://ol-solr1:8984/solr/openlibrary
281- --solr-next
281+ - EXTRA_OPTS=--solr-next
282282 volumes :
283283 - solr-updater-data:/solr-updater-data
284284 - ../olsystem:/olsystem
Original file line number Diff line number Diff line change 11"""Search utilities."""
22
3+ import os
4+
35from infogami import config
46from openlibrary .utils .solr import Solr
57
911def get_solr ():
1012 global _ACTIVE_SOLR
1113 if not _ACTIVE_SOLR :
12- base_url = config .plugin_worksearch .get ('solr_base_url' )
14+ if os .environ .get ('OL_SOLR_BASE_URL' ):
15+ base_url = os .environ ['OL_SOLR_BASE_URL' ]
16+ else :
17+ base_url = config .plugin_worksearch .get ('solr_base_url' )
18+
1319 _ACTIVE_SOLR = Solr (base_url )
1420 return _ACTIVE_SOLR
Original file line number Diff line number Diff line change 11import json
22import logging
3+ import os
34from dataclasses import dataclass , field
45
56import httpx
@@ -30,9 +31,13 @@ def get_solr_base_url():
3031 """
3132 global solr_base_url
3233
33- load_config ()
34+ if solr_base_url is not None :
35+ return solr_base_url
3436
35- if not solr_base_url :
37+ if os .environ .get ('OL_SOLR_BASE_URL' ):
38+ solr_base_url = os .environ ['OL_SOLR_BASE_URL' ]
39+ else :
40+ load_config ()
3641 solr_base_url = config .runtime_config ['plugin_worksearch' ]['solr_base_url' ]
3742
3843 return solr_base_url
Original file line number Diff line number Diff line change @@ -277,13 +277,15 @@ async def main(
277277 state_file : str = 'solr-update.state' ,
278278 exclude_edits_containing : str | None = None ,
279279 ol_url = 'http://openlibrary.org/' ,
280- solr_url : str | None = None ,
281280 solr_next : bool = False ,
282281 socket_timeout : int = 10 ,
283282 load_ia_scans : bool = False ,
284283 initial_state : str | None = None ,
285284):
286285 """
286+ Useful environment variables:
287+ - OL_SOLR_BASE_URL: Override the Solr base URL
288+
287289 :param debugger: Wait for a debugger to attach before beginning
288290 :param exclude_edits_containing: Don't index matching edits
289291 :param solr_url: If wanting to override what's in the config file
@@ -312,9 +314,6 @@ async def main(
312314 host = web .lstrips (ol_url , "http://" ).strip ("/" )
313315 update .set_query_host (host )
314316
315- if solr_url :
316- update .set_solr_base_url (solr_url )
317-
318317 update .set_solr_next (solr_next )
319318 set_osp_dump_location (osp_dump )
320319
You can’t perform that action at this time.
0 commit comments