mirror of
https://github.com/zulip/zulip.git
synced 2026-07-15 21:03:26 +08:00
The previous version ended up being (at least sometimes) wrong after the recent deployment system changes. (imported from commit dec3beb1b1bf8b9c9ad6820b93b0a5d730d020e8)
44 lines
1.3 KiB
Python
Executable File
44 lines
1.3 KiB
Python
Executable File
#!/usr/bin/env python
|
|
import os
|
|
import sys
|
|
import subprocess
|
|
import pylibmc
|
|
import traceback
|
|
import logging
|
|
|
|
logging.basicConfig(format="%(asctime)s restart-server: %(message)s",
|
|
level=logging.INFO)
|
|
|
|
# Color codes
|
|
OKBLUE = '\033[94m'
|
|
OKGREEN = '\033[92m'
|
|
WARNING = '\033[93m'
|
|
FAIL = '\033[91m'
|
|
ENDC = '\033[0m'
|
|
|
|
os.chdir("/home/humbug/humbug-deployments/current")
|
|
|
|
# Restart the FastCGI process, which is running in a shell loop in screen.
|
|
# TODO: real daemonization
|
|
logging.info("Killing daemons")
|
|
for cmd in ('runfcgi', 'runtornado', "process_user_activity", "subscribe_new_users", "send_confirmation_emails"):
|
|
try:
|
|
subprocess.check_call(["pkill", "-f", "manage.py " + cmd])
|
|
except subprocess.CalledProcessError:
|
|
print "%sCould not kill %s; is it running?%s" % (WARNING, cmd, ENDC)
|
|
|
|
logging.info("Flushing memcached")
|
|
try:
|
|
if not pylibmc.Client(['127.0.0.1']).flush_all():
|
|
print "%sflush_all returned False%s" % (WARNING, ENDC)
|
|
# There doesn't seem to be a method to close a pylibmc Client object.
|
|
except:
|
|
print "%sCould not flush cache:%s" % (WARNING, ENDC)
|
|
traceback.print_exc()
|
|
|
|
logging.info("Refilling memcached caches")
|
|
subprocess.check_call(["python", "./manage.py", "fill_memcached_caches"])
|
|
|
|
logging.info("Done!")
|
|
print OKGREEN + "Application restarted successfully!" + ENDC
|