Добавлена настройка соединения Sphinx (возможен Unix Socket)

This commit is contained in:
Jack Stdin 2016-02-21 00:15:12 +03:00
parent c2799674b3
commit 5a5c2211db
5 changed files with 14 additions and 9 deletions

View File

@ -5,8 +5,7 @@ class basic:
class sphinx_conf:
host_name = "localhost"
port = 9312
listen = "127.0.0.1:9312"
index_addjobj = "idx_fias_addrobj"
index_sugg = "idx_fias_sugg"
var_dir = None

View File

@ -4,8 +4,7 @@ from __future__ import absolute_import
from .common import *
sphinx_conf.host_name = "localhost"
sphinx_conf.port = 9312
sphinx_conf.listen = "127.0.0.1:9312"
sphinx_conf.var_dir = "C:\\Sphinx"
db_conf.database = "postgres"

View File

@ -25,13 +25,20 @@ class SphinxSearch:
def __init__(self, db):
self.db = db
sphinx_host = sphinx_conf.listen
sphinx_port = None
if ":" in sphinx_conf.listen:
sphinx_host, sphinx_port = sphinx_conf.listen.split(":")
sphinx_port = int(sphinx_port)
self.client_sugg = sphinxapi.SphinxClient()
self.client_sugg.SetServer(sphinx_conf.host_name, sphinx_conf.port)
self.client_sugg.SetServer(sphinx_host, sphinx_port)
self.client_sugg.SetLimits(0, self.max_result)
self.client_sugg.SetConnectTimeout(3.0)
self.client_show = sphinxapi.SphinxClient()
self.client_show.SetServer(sphinx_conf.host_name, sphinx_conf.port)
self.client_show.SetServer(sphinx_host, sphinx_port)
self.client_show.SetLimits(0, self.max_result)
self.client_show.SetConnectTimeout(3.0)

View File

@ -21,7 +21,6 @@ class SphinxHelper:
if not os.path.exists(folders.temp):
os.makedirs(folders.temp)
def configure_indexer(self, indexer_binary, config_filename):
logging.info("Start configuring Sphinx...")
self.index_binary = indexer_binary
@ -144,7 +143,8 @@ class SphinxHelper:
out_filename = os.path.abspath(config_fname)
logging.info("Creating main config %s...", out_filename)
conf_data = template('aore/templates/sphinx/sphinx.conf', sphinx_var_path=sphinx_conf.var_dir)
conf_data = template('aore/templates/sphinx/sphinx.conf', sphinx_listen=sphinx_conf.listen,
sphinx_var_path=sphinx_conf.var_dir)
f = open(out_filename, "w")
for fname, fpath in self.files.iteritems():

View File

@ -18,7 +18,7 @@ indexer
searchd
{
listen = 127.0.0.1:9312
listen = {{ sphinx_listen }}
# required by RT-indexes
workers = threads