mirror of https://github.com/zulip/zulip.git
process_fts_updates: Fix check for USING_PGROONGA to not use settings.
The Zulip server's settings are only available if process-fts-updates is running is on the same server as a Zulip production deployment. So we instead check whether we have pgroonga configured in /etc/zulip/zulip.conf.
This commit is contained in:
parent
890417f8eb
commit
a38d846e8b
|
@ -27,6 +27,7 @@ import psycopg2.extensions
|
||||||
import select
|
import select
|
||||||
import time
|
import time
|
||||||
import logging
|
import logging
|
||||||
|
import six
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
@ -35,7 +36,7 @@ def update_fts_columns(cursor):
|
||||||
cursor.execute("SELECT id, message_id FROM fts_update_log;")
|
cursor.execute("SELECT id, message_id FROM fts_update_log;")
|
||||||
ids = []
|
ids = []
|
||||||
for (id, message_id) in cursor.fetchall():
|
for (id, message_id) in cursor.fetchall():
|
||||||
if settings.USING_PGROONGA:
|
if USING_PGROONGA:
|
||||||
cursor.execute("UPDATE zerver_message SET "
|
cursor.execute("UPDATE zerver_message SET "
|
||||||
"search_pgroonga = "
|
"search_pgroonga = "
|
||||||
"subject || ' ' || rendered_content "
|
"subject || ' ' || rendered_content "
|
||||||
|
@ -72,6 +73,14 @@ except ImportError as e:
|
||||||
# postgres server; in that case, one can just connect to localhost
|
# postgres server; in that case, one can just connect to localhost
|
||||||
remote_postgres_host = ''
|
remote_postgres_host = ''
|
||||||
|
|
||||||
|
# Since we don't want a hard dependency on being able to access the
|
||||||
|
# Zulip settings (as we may not be running on a server that has that
|
||||||
|
# data), we determine whether we're using pgroonga using
|
||||||
|
# /etc/zulip/zulip.conf.
|
||||||
|
config_file = six.moves.configparser.RawConfigParser()
|
||||||
|
config_file.read("/etc/zulip/zulip.conf")
|
||||||
|
USING_PGROONGA = config_file.has_option('machine', 'pgroonga')
|
||||||
|
|
||||||
if remote_postgres_host != '':
|
if remote_postgres_host != '':
|
||||||
postgres_password = ''
|
postgres_password = ''
|
||||||
if settings.DATABASES['default']['PASSWORD'] is not None:
|
if settings.DATABASES['default']['PASSWORD'] is not None:
|
||||||
|
|
Loading…
Reference in New Issue