mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 06:23:38 +00:00
db: Make USING_PGROONGA logic clearer.
We only need to read the `zulip.conf` file to determine if we're using PGROONGA if we are on the PostgreSQL machine, with no access to Django. Co-authored-by: Adam Birds <adam.birds@adbwebdesigns.co.uk>
This commit is contained in:
committed by
Tim Abbott
parent
75bf19c9d9
commit
add6971ad9
@@ -96,6 +96,7 @@ def am_master(cursor: psycopg2.extensions.cursor) -> bool:
|
|||||||
|
|
||||||
pg_args = {}
|
pg_args = {}
|
||||||
|
|
||||||
|
USING_PGROONGA = False
|
||||||
try:
|
try:
|
||||||
# Case (1); we insert the path to the development root.
|
# Case (1); we insert the path to the development root.
|
||||||
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../../../..")))
|
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "../../../..")))
|
||||||
@@ -107,7 +108,6 @@ try:
|
|||||||
pg_args["host"] = settings.REMOTE_POSTGRES_HOST
|
pg_args["host"] = settings.REMOTE_POSTGRES_HOST
|
||||||
if settings.REMOTE_POSTGRES_PORT != "":
|
if settings.REMOTE_POSTGRES_PORT != "":
|
||||||
pg_args["port"] = settings.REMOTE_POSTGRES_PORT
|
pg_args["port"] = settings.REMOTE_POSTGRES_PORT
|
||||||
USING_PGROONGA = settings.USING_PGROONGA
|
|
||||||
pg_args["password"] = ""
|
pg_args["password"] = ""
|
||||||
if settings.DATABASES["default"]["PASSWORD"] is not None:
|
if settings.DATABASES["default"]["PASSWORD"] is not None:
|
||||||
pg_args["password"] = settings.DATABASES["default"]["PASSWORD"]
|
pg_args["password"] = settings.DATABASES["default"]["PASSWORD"]
|
||||||
@@ -118,22 +118,15 @@ try:
|
|||||||
else:
|
else:
|
||||||
pg_args["sslmode"] = "verify-full"
|
pg_args["sslmode"] = "verify-full"
|
||||||
pg_args["connect_timeout"] = "600"
|
pg_args["connect_timeout"] = "600"
|
||||||
|
USING_PGROONGA = settings.USING_PGROONGA
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# Case (3); we know that the PostgreSQL server is on this
|
# Case (3); we know that the PostgreSQL server is on this
|
||||||
# host.
|
# host.
|
||||||
USING_PGROONGA = False
|
|
||||||
pg_args["user"] = "zulip"
|
pg_args["user"] = "zulip"
|
||||||
|
|
||||||
# Since we don't want a hard dependency on being able to access the
|
config_file = configparser.RawConfigParser()
|
||||||
# Zulip settings (as we may not be running on a server that has that
|
config_file.read("/etc/zulip/zulip.conf")
|
||||||
# data), we determine whether we're using PGroonga using
|
if config_file.has_option("machine", "pgroonga"):
|
||||||
# /etc/zulip/zulip.conf.
|
|
||||||
#
|
|
||||||
# However, we still also check the `USING_PGROONGA` variable, since
|
|
||||||
# that's all we have in development.
|
|
||||||
config_file = configparser.RawConfigParser()
|
|
||||||
config_file.read("/etc/zulip/zulip.conf")
|
|
||||||
if config_file.has_option("machine", "pgroonga"):
|
|
||||||
USING_PGROONGA = True
|
USING_PGROONGA = True
|
||||||
|
|
||||||
conn = None
|
conn = None
|
||||||
|
|||||||
Reference in New Issue
Block a user