Files
zulip/scripts/restart-server
Zev Benjamin a363b7185d restart-server: Use 'all' instead of specifying the supervisor jobs to operate on explicitly
This shaves about 1.5 seconds off our restart time on ls-dev (9s ->
7.5s).  Still too slow, but it's a little bit better.

(imported from commit acef4c0027b77053497ef6e9f7aa4b61703205c3)
2013-11-15 15:23:02 -05:00

41 lines
1.4 KiB
Python
Executable File

#!/usr/bin/env python
import os
import sys
import pwd
import subprocess
import logging
import time
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
from zulip_tools import ENDC, OKGREEN, DEPLOYMENTS_DIR
logging.basicConfig(format="%(asctime)s restart-server: %(message)s",
level=logging.INFO)
deploy_path = os.path.realpath(os.path.join(os.path.dirname(__file__), '..'))
os.chdir(deploy_path)
if pwd.getpwuid(os.getuid())[0] != "zulip":
logging.error("Must be run as user 'zulip'.")
sys.exit(1)
# Send a statsd event on restarting the server
subprocess.check_call(["python", "./manage.py", "send_stats", "incr", "events.server_restart", str(int(time.time()))])
logging.info("Filling memcached caches")
subprocess.check_call(["python", "./manage.py", "fill_memcached_caches"])
# Restart the FastCGI and related processes via supervisorctl.
logging.info("Killing daemons")
subprocess.check_call(["supervisorctl", "stop", "all"])
subprocess.check_call(["ln", '-nsf', deploy_path, os.path.join(DEPLOYMENTS_DIR, "current")])
subprocess.check_call(["supervisorctl", "start", "all"])
using_sso = subprocess.check_output(['./bin/get-django-setting', 'USING_SSO'])
if using_sso.strip() == 'True':
logging.info("Restarting Apache WSGI process...")
subprocess.check_call(["pkill", "-f", "apache2", "-u", "zulip"])
logging.info("Done!")
print OKGREEN + "Application restarted successfully!" + ENDC