mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-04-13 09:42:01 +00:00
Correcting mongodb on local installs since there is no auth.
This commit is contained in:
parent
96b29bb037
commit
3804fbba5d
4 changed files with 27 additions and 10 deletions
|
@ -57,6 +57,7 @@ class TextImporter:
|
||||||
|
|
||||||
if not use_mercury or not results:
|
if not use_mercury or not results:
|
||||||
logging.user(self.request, "~SN~FRFailed~FY to fetch ~FGoriginal text~FY with Mercury, trying readability...", warn_color=False)
|
logging.user(self.request, "~SN~FRFailed~FY to fetch ~FGoriginal text~FY with Mercury, trying readability...", warn_color=False)
|
||||||
|
|
||||||
results = self.fetch_manually(skip_save=skip_save, return_document=return_document)
|
results = self.fetch_manually(skip_save=skip_save, return_document=return_document)
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
@ -106,10 +107,18 @@ class TextImporter:
|
||||||
if not resp:
|
if not resp:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@timelimit(5)
|
||||||
|
def extract_text(resp):
|
||||||
try:
|
try:
|
||||||
text = resp.text
|
text = resp.text
|
||||||
except (LookupError, TypeError):
|
except (LookupError, TypeError):
|
||||||
text = resp.content
|
text = resp.content
|
||||||
|
return text
|
||||||
|
try:
|
||||||
|
text = extract_text(resp)
|
||||||
|
except TimeoutError:
|
||||||
|
logging.user(self.request, "~SN~FRFailed~FY to fetch ~FGoriginal text~FY: timed out on resp.text")
|
||||||
|
return
|
||||||
|
|
||||||
# if self.debug:
|
# if self.debug:
|
||||||
# logging.user(self.request, "~FBOriginal text's website: %s" % text)
|
# logging.user(self.request, "~FBOriginal text's website: %s" % text)
|
||||||
|
@ -227,6 +236,8 @@ class TextImporter:
|
||||||
headers["content-type"] = "application/json"
|
headers["content-type"] = "application/json"
|
||||||
headers["x-api-key"] = mercury_api_key
|
headers["x-api-key"] = mercury_api_key
|
||||||
domain = Site.objects.get_current().domain
|
domain = Site.objects.get_current().domain
|
||||||
|
if settings.DOCKERBUILD:
|
||||||
|
domain = 'haproxy'
|
||||||
url = f"https://{domain}/rss_feeds/original_text_fetcher?url={url}"
|
url = f"https://{domain}/rss_feeds/original_text_fetcher?url={url}"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -95,8 +95,7 @@ MONGO_DB = {
|
||||||
}
|
}
|
||||||
MONGO_ANALYTICS_DB = {
|
MONGO_ANALYTICS_DB = {
|
||||||
'name': 'nbanalytics',
|
'name': 'nbanalytics',
|
||||||
'host': 'db_mongo',
|
'host': 'db_mongo:29019',
|
||||||
'port': 29019,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MONGODB_SLAVE = {
|
MONGODB_SLAVE = {
|
||||||
|
|
|
@ -696,11 +696,13 @@ MONGO_ANALYTICS_DB_DEFAULTS = {
|
||||||
'name': 'nbanalytics',
|
'name': 'nbanalytics',
|
||||||
'host': f'db_mongo_analytics:{MONGO_PORT}',
|
'host': f'db_mongo_analytics:{MONGO_PORT}',
|
||||||
'alias': 'nbanalytics',
|
'alias': 'nbanalytics',
|
||||||
'username': 'newsblur',
|
|
||||||
'password': 'newsblur',
|
|
||||||
}
|
}
|
||||||
MONGO_ANALYTICS_DB = dict(MONGO_ANALYTICS_DB_DEFAULTS, **MONGO_ANALYTICS_DB)
|
MONGO_ANALYTICS_DB = dict(MONGO_ANALYTICS_DB_DEFAULTS, **MONGO_ANALYTICS_DB)
|
||||||
MONGOANALYTICSDB = connect(db=MONGO_ANALYTICS_DB['name'], host=f"mongodb://{MONGO_ANALYTICS_DB['username']}:{MONGO_ANALYTICS_DB['password']}@{MONGO_ANALYTICS_DB['host']}/?authSource=admin", alias="nbanalytics")
|
if 'username' in MONGO_ANALYTICS_DB:
|
||||||
|
MONGOANALYTICSDB = connect(db=MONGO_ANALYTICS_DB['name'], host=f"mongodb://{MONGO_ANALYTICS_DB['username']}:{MONGO_ANALYTICS_DB['password']}@{MONGO_ANALYTICS_DB['host']}/?authSource=admin", alias="nbanalytics")
|
||||||
|
else:
|
||||||
|
MONGOANALYTICSDB = connect(db=MONGO_ANALYTICS_DB['name'], host=f"mongodb://{MONGO_ANALYTICS_DB['host']}/", alias="nbanalytics")
|
||||||
|
|
||||||
|
|
||||||
# =========
|
# =========
|
||||||
# = Redis =
|
# = Redis =
|
||||||
|
|
|
@ -665,13 +665,18 @@ class FeedFetcherWorker:
|
||||||
"""Update feed, since it may have changed"""
|
"""Update feed, since it may have changed"""
|
||||||
return Feed.get_by_id(feed_id)
|
return Feed.get_by_id(feed_id)
|
||||||
|
|
||||||
def process_feed_wrapper(self, feed_queue):
|
def reset_database_connections(self):
|
||||||
connection._connections = {}
|
connection._connections = {}
|
||||||
connection._connection_settings ={}
|
connection._connection_settings ={}
|
||||||
connection._dbs = {}
|
connection._dbs = {}
|
||||||
settings.MONGODB = connect(settings.MONGO_DB_NAME, **settings.MONGO_DB)
|
settings.MONGODB = connect(settings.MONGO_DB_NAME, **settings.MONGO_DB)
|
||||||
|
if 'username' in settings.MONGO_ANALYTICS_DB:
|
||||||
settings.MONGOANALYTICSDB = connect(db=settings.MONGO_ANALYTICS_DB['name'], host=f"mongodb://{settings.MONGO_ANALYTICS_DB['username']}:{settings.MONGO_ANALYTICS_DB['password']}@{settings.MONGO_ANALYTICS_DB['host']}/?authSource=admin", alias="nbanalytics")
|
settings.MONGOANALYTICSDB = connect(db=settings.MONGO_ANALYTICS_DB['name'], host=f"mongodb://{settings.MONGO_ANALYTICS_DB['username']}:{settings.MONGO_ANALYTICS_DB['password']}@{settings.MONGO_ANALYTICS_DB['host']}/?authSource=admin", alias="nbanalytics")
|
||||||
|
else:
|
||||||
|
settings.MONGOANALYTICSDB = connect(db=settings.MONGO_ANALYTICS_DB['name'], host=f"mongodb://{settings.MONGO_ANALYTICS_DB['host']}/", alias="nbanalytics")
|
||||||
|
|
||||||
|
def process_feed_wrapper(self, feed_queue):
|
||||||
|
self.reset_database_connections()
|
||||||
|
|
||||||
delta = None
|
delta = None
|
||||||
current_process = multiprocessing.current_process()
|
current_process = multiprocessing.current_process()
|
||||||
|
|
Loading…
Add table
Reference in a new issue