1
0
Fork 0
mirror of https://gitlab.com/SIGBUS/nyaa.git synced 2024-12-22 14:40:00 +00:00

config: Add Elasticsearch hosts (#492)

This commit is contained in:
Anna-Maria Meriniemi 2018-07-10 08:26:23 +03:00 committed by Arylide
parent 56a670977e
commit 5c8b119611
4 changed files with 9 additions and 3 deletions

View file

@ -144,6 +144,8 @@ ENABLE_ELASTIC_SEARCH_HIGHLIGHT = False
ES_MAX_SEARCH_RESULT = 1000 ES_MAX_SEARCH_RESULT = 1000
# ES index name generally (nyaa or sukebei) # ES index name generally (nyaa or sukebei)
ES_INDEX_NAME = SITE_FLAVOR ES_INDEX_NAME = SITE_FLAVOR
# ES hosts
ES_HOSTS = ['localhost:9200']
################ ################
## Commenting ## ## Commenting ##

View file

@ -18,7 +18,7 @@ from nyaa import create_app, models
from nyaa.extensions import db from nyaa.extensions import db
app = create_app('config') app = create_app('config')
es = Elasticsearch(timeout=30) es = Elasticsearch(hosts=app.config['ES_HOSTS'], timeout=30)
ic = IndicesClient(es) ic = IndicesClient(es)
def pad_bytes(in_bytes, size): def pad_bytes(in_bytes, size):

View file

@ -185,7 +185,7 @@ def search_elastic(term='', user=None, sort='id', order='desc',
if page > 4294967295: if page > 4294967295:
flask.abort(404) flask.abort(404)
es_client = Elasticsearch() es_client = Elasticsearch(hosts=app.config['ES_HOSTS'])
es_sort_keys = { es_sort_keys = {
'id': 'id', 'id': 'id',

View file

@ -34,7 +34,11 @@ from elasticsearch.helpers import bulk, BulkIndexError
from pymysqlreplication import BinLogStreamReader from pymysqlreplication import BinLogStreamReader
from pymysqlreplication.row_event import UpdateRowsEvent, DeleteRowsEvent, WriteRowsEvent from pymysqlreplication.row_event import UpdateRowsEvent, DeleteRowsEvent, WriteRowsEvent
from datetime import datetime from datetime import datetime
from nyaa import create_app, db, models
from nyaa.models import TorrentFlags from nyaa.models import TorrentFlags
app = create_app('config')
import sys import sys
import json import json
import time import time
@ -262,7 +266,7 @@ class EsPoster(ExitingThread):
self.flush_interval = flush_interval self.flush_interval = flush_interval
def run_happy(self): def run_happy(self):
es = Elasticsearch(timeout=30) es = Elasticsearch(hosts=app.config['ES_HOSTS'], timeout=30)
last_save = time.time() last_save = time.time()
since_last = 0 since_last = 0