mirror of https://github.com/zulip/zulip.git
restart-server: Factor out argparser, to allow reuse.
This commit is contained in:
parent
93f3da4c05
commit
fb3368b482
|
@ -653,6 +653,23 @@ def deport(netloc: str) -> str:
|
||||||
return "[" + r.hostname + "]" if ":" in r.hostname else r.hostname
|
return "[" + r.hostname + "]" if ":" in r.hostname else r.hostname
|
||||||
|
|
||||||
|
|
||||||
|
def start_arg_parser(action: str, add_help: bool = False) -> argparse.ArgumentParser:
|
||||||
|
parser = argparse.ArgumentParser(add_help=add_help)
|
||||||
|
parser.add_argument("--fill-cache", action="store_true", help="Fill the memcached caches")
|
||||||
|
if action == "restart":
|
||||||
|
parser.add_argument(
|
||||||
|
"--less-graceful",
|
||||||
|
action="store_true",
|
||||||
|
help="Restart with more concern for expediency than minimizing availability interruption",
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
"--skip-tornado",
|
||||||
|
action="store_true",
|
||||||
|
help="Do not restart Tornado processes",
|
||||||
|
)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
cmd = sys.argv[1]
|
cmd = sys.argv[1]
|
||||||
if cmd == "make_deploy_path":
|
if cmd == "make_deploy_path":
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
import argparse
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import pwd
|
import pwd
|
||||||
|
@ -20,6 +19,7 @@ from scripts.lib.zulip_tools import (
|
||||||
has_process_fts_updates,
|
has_process_fts_updates,
|
||||||
list_supervisor_processes,
|
list_supervisor_processes,
|
||||||
overwrite_symlink,
|
overwrite_symlink,
|
||||||
|
start_arg_parser,
|
||||||
)
|
)
|
||||||
|
|
||||||
action = "restart"
|
action = "restart"
|
||||||
|
@ -30,19 +30,7 @@ verbing = action.title() + "ing"
|
||||||
logging.Formatter.converter = time.gmtime
|
logging.Formatter.converter = time.gmtime
|
||||||
logging.basicConfig(format=f"%(asctime)s {action}-server: %(message)s", level=logging.INFO)
|
logging.basicConfig(format=f"%(asctime)s {action}-server: %(message)s", level=logging.INFO)
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
parser = start_arg_parser(action=action, add_help=True)
|
||||||
parser.add_argument("--fill-cache", action="store_true", help="Fill the memcached caches")
|
|
||||||
if action == "restart":
|
|
||||||
parser.add_argument(
|
|
||||||
"--less-graceful",
|
|
||||||
action="store_true",
|
|
||||||
help="Restart with more concern for expediency than minimizing availability interruption",
|
|
||||||
)
|
|
||||||
parser.add_argument(
|
|
||||||
"--skip-tornado",
|
|
||||||
action="store_true",
|
|
||||||
help="Do not restart Tornado processes",
|
|
||||||
)
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
deploy_path = os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))
|
deploy_path = os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))
|
||||||
|
|
Loading…
Reference in New Issue