mirror of
https://github.com/zulip/zulip.git
synced 2025-11-03 13:33:24 +00:00
This commits adds the necessary puppet configuration and installer/upgrade code for installing and managing the thumbor service in production. This configuration is gated by the 'thumbor.pp' manifest being enabled (which is not yet the default), and so this commit should have no effect in a default Zulip production environment (or in the long term, in any Zulip production server that isn't using thumbor). Credit for this effort is shared by @TigorC (who initiated the work on this project), @joshland (who did a great deal of work on this and got it working during PyCon 2017) and @adnrs96, who completed the work.
55 lines
2.1 KiB
Python
Executable File
55 lines
2.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
import os
|
|
import sys
|
|
import pwd
|
|
import subprocess
|
|
import logging
|
|
import time
|
|
|
|
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
|
from scripts.lib.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()).pw_name != "zulip":
|
|
logging.error("Must be run as user 'zulip'.")
|
|
sys.exit(1)
|
|
|
|
# Send a statsd event on restarting the server
|
|
subprocess.check_call(["./manage.py", "send_stats", "incr", "events.server_restart", str(int(time.time()))])
|
|
|
|
logging.info("Filling memcached caches")
|
|
subprocess.check_call(["./manage.py", "fill_memcached_caches"])
|
|
|
|
core_server_services = ["zulip-django", "zulip-tornado", "zulip-senders:*"]
|
|
if os.path.exists("/etc/supervisor/conf.d/thumbor.conf"):
|
|
core_server_services.append("zulip-thumbor")
|
|
|
|
# Restart the uWSGI and related processes via supervisorctl.
|
|
logging.info("Stopping workers")
|
|
subprocess.check_call(["supervisorctl", "stop", "zulip-workers:*"])
|
|
logging.info("Stopping server core")
|
|
subprocess.check_call(["supervisorctl", "stop"] + core_server_services)
|
|
|
|
current_symlink = os.path.join(DEPLOYMENTS_DIR, "current")
|
|
last_symlink = os.path.join(DEPLOYMENTS_DIR, "last")
|
|
if os.readlink(current_symlink) != deploy_path:
|
|
subprocess.check_call(["ln", '-nsf', os.readlink(current_symlink), last_symlink])
|
|
subprocess.check_call(["ln", '-nsf', deploy_path, current_symlink])
|
|
logging.info("Starting server core")
|
|
subprocess.check_call(["supervisorctl", "start"] + core_server_services)
|
|
logging.info("Starting workers")
|
|
subprocess.check_call(["supervisorctl", "start", "zulip-workers:*"])
|
|
|
|
using_sso = subprocess.check_output(['./scripts/get-django-setting', 'USING_APACHE_SSO'])
|
|
if using_sso.strip() == b'True':
|
|
logging.info("Restarting Apache WSGI process...")
|
|
subprocess.check_call(["pkill", "-f", "apache2", "-u", "zulip"])
|
|
|
|
logging.info("Done!")
|
|
print(OKGREEN + "Application restarted successfully!" + ENDC)
|