restart-server: Send client reload events in the background.

For deploys with --skip-puppet, this makes the output visible much
more promptly.
This commit is contained in:
Alex Vandiver
2025-06-11 16:35:24 +00:00
committed by Tim Abbott
parent e243fc67fa
commit 6f1950ac0e
3 changed files with 21 additions and 3 deletions

View File

@@ -367,7 +367,7 @@ else:
subprocess.check_call(["./scripts/lib/run_hooks.py", "post-deploy", *hooks_args])
if not args.skip_client_reloads and not args.only_django:
subprocess.check_call(["./scripts/reload-clients"], preexec_fn=su_to_zulip)
subprocess.check_call(["./scripts/reload-clients", "--background"], preexec_fn=su_to_zulip)
if args.audit_fts_indexes:
logging.info("Correcting full-text search indexes for updated dictionary files")

View File

@@ -31,6 +31,7 @@ parser = argparse.ArgumentParser()
parser.add_argument(
"--rate", type=int, help="Number of clients to reload per second", default=reload_rate
)
parser.add_argument("--background", action="store_true", help="Daemonize the process")
args = parser.parse_args()
reload_rate = args.rate
@@ -49,8 +50,24 @@ retry = Retry(total=3, backoff_factor=1, allowed_methods=Retry.DEFAULT_ALLOWED_M
c = requests.Session()
c.mount("http://", HTTPAdapter(max_retries=retry))
log_filename = None
if args.background:
# Double-fork to daemonize
pid = os.fork()
if pid > 0:
sys.exit(0)
os.setsid()
pid = os.fork()
if pid > 0:
sys.exit(0)
log_filename = "/var/log/zulip/reload-clients.log"
logging.Formatter.converter = time.gmtime
logging.basicConfig(format="%(asctime)s reload-clients: %(message)s", level=logging.INFO)
logging.basicConfig(
format="%(asctime)s reload-clients: %(message)s",
level=logging.INFO,
filename=log_filename,
)
first = True
server_total = 0

View File

@@ -245,7 +245,8 @@ if (action == "start" or args.less_graceful) and not args.only_django:
if has_application_server() and not args.skip_client_reloads and not args.only_django:
# All of the servers have been (re)started; now enqueue events in
# the Tornado servers to tell clients to reload.
subprocess.check_call(["./scripts/reload-clients"])
logging.info("Sending reload events to clients in the background")
subprocess.check_call(["./scripts/reload-clients", "--background"])
logging.info("Done!")
print(OKGREEN + f"Zulip {action}ed successfully!" + ENDC)