diff --git a/aore/config/common.py b/aore/config/common.py index 3261db5..161b529 100644 --- a/aore/config/common.py +++ b/aore/config/common.py @@ -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 diff --git a/aore/config/dev.py b/aore/config/dev.py index 67ab7f7..2364162 100644 --- a/aore/config/dev.py +++ b/aore/config/dev.py @@ -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" diff --git a/aore/fias/search.py b/aore/fias/search.py index 2b18353..1b96347 100644 --- a/aore/fias/search.py +++ b/aore/fias/search.py @@ -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) diff --git a/aore/miscutils/sphinx.py b/aore/miscutils/sphinx.py index 580c6d9..751de25 100644 --- a/aore/miscutils/sphinx.py +++ b/aore/miscutils/sphinx.py @@ -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(): diff --git a/aore/templates/sphinx/sphinx.conf b/aore/templates/sphinx/sphinx.conf index aa890d1..f193aaf 100644 --- a/aore/templates/sphinx/sphinx.conf +++ b/aore/templates/sphinx/sphinx.conf @@ -18,7 +18,7 @@ indexer searchd { - listen = 127.0.0.1:9312 + listen = {{ sphinx_listen }} # required by RT-indexes workers = threads