mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 17:07:07 +00:00
Move PERSISTENT_QUEUE_FILENAME into settings.py.
(imported from commit e7d1378fd0cb3f3d894ff4a5b6ee44212bf3ce34)
This commit is contained in:
@@ -335,10 +335,12 @@ if DEPLOYED:
|
|||||||
SERVER_LOG_PATH = "/home/humbug/logs/server.log"
|
SERVER_LOG_PATH = "/home/humbug/logs/server.log"
|
||||||
EVENT_LOG_DIR = '/home/humbug/logs/event_log'
|
EVENT_LOG_DIR = '/home/humbug/logs/event_log'
|
||||||
STATS_DIR = '/home/humbug/stats'
|
STATS_DIR = '/home/humbug/stats'
|
||||||
|
PERSISTENT_QUEUE_FILENAME = "/home/humbug/tornado/event_queues.pickle"
|
||||||
else:
|
else:
|
||||||
EVENT_LOG_DIR = 'event_log'
|
EVENT_LOG_DIR = 'event_log'
|
||||||
SERVER_LOG_PATH = "server.log"
|
SERVER_LOG_PATH = "server.log"
|
||||||
STATS_DIR = 'stats'
|
STATS_DIR = 'stats'
|
||||||
|
PERSISTENT_QUEUE_FILENAME = "event_queues.pickle"
|
||||||
|
|
||||||
LOGGING = {
|
LOGGING = {
|
||||||
'version': 1,
|
'version': 1,
|
||||||
|
|||||||
@@ -154,16 +154,13 @@ def gc_event_queues():
|
|||||||
stats.update_stat('tornado.active_queues', len(clients))
|
stats.update_stat('tornado.active_queues', len(clients))
|
||||||
stats.update_stat('tornado.active_users', len(user_clients))
|
stats.update_stat('tornado.active_users', len(user_clients))
|
||||||
|
|
||||||
PERSISTENT_QUEUE_FILENAME = os.path.join(os.path.dirname(__file__),
|
|
||||||
"..", "..", "event_queues.pickle")
|
|
||||||
|
|
||||||
def dump_event_queues():
|
def dump_event_queues():
|
||||||
start = time.time()
|
start = time.time()
|
||||||
# Remove unpickle-able attributes
|
# Remove unpickle-able attributes
|
||||||
for client in clients.itervalues():
|
for client in clients.itervalues():
|
||||||
client.prepare_for_pickling()
|
client.prepare_for_pickling()
|
||||||
|
|
||||||
with file(PERSISTENT_QUEUE_FILENAME, "w") as stored_queues:
|
with file(settings.PERSISTENT_QUEUE_FILENAME, "w") as stored_queues:
|
||||||
pickle.dump(clients, stored_queues)
|
pickle.dump(clients, stored_queues)
|
||||||
|
|
||||||
logging.info('Tornado dumped %d event queues in %.3fs'
|
logging.info('Tornado dumped %d event queues in %.3fs'
|
||||||
@@ -173,7 +170,7 @@ def load_event_queues():
|
|||||||
global clients
|
global clients
|
||||||
start = time.time()
|
start = time.time()
|
||||||
try:
|
try:
|
||||||
with file(PERSISTENT_QUEUE_FILENAME, "r") as stored_queues:
|
with file(settings.PERSISTENT_QUEUE_FILENAME, "r") as stored_queues:
|
||||||
clients = pickle.load(stored_queues)
|
clients = pickle.load(stored_queues)
|
||||||
except (IOError, EOFError):
|
except (IOError, EOFError):
|
||||||
pass
|
pass
|
||||||
@@ -197,7 +194,7 @@ def setup_event_queue():
|
|||||||
signal.signal(signal.SIGTERM, lambda signum, stack: sys.exit(1))
|
signal.signal(signal.SIGTERM, lambda signum, stack: sys.exit(1))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.remove(PERSISTENT_QUEUE_FILENAME)
|
os.remove(settings.PERSISTENT_QUEUE_FILENAME)
|
||||||
except OSError:
|
except OSError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user