zephyr_mirror: Add a --no-forward-from-humbug option.

We'll use this to only have one of our shards forward from Humbug.

(imported from commit a6f3c2180b49c1fa826baf1ae9e7e3ba252a5bfa)
This commit is contained in:
Tim Abbott 2012-11-27 10:25:49 -05:00
parent 975c8ef5b0
commit bfec56661e

View file

@ -177,6 +177,7 @@ def maybe_restart_mirroring_script():
logger.warning("") logger.warning("")
logger.warning("zephyr mirroring script has been updated; restarting...") logger.warning("zephyr mirroring script has been updated; restarting...")
try: try:
if child_pid is not None:
os.kill(child_pid, signal.SIGTERM) os.kill(child_pid, signal.SIGTERM)
except OSError: except OSError:
# We don't care if the child process no longer exists, so just print the error # We don't care if the child process no longer exists, so just print the error
@ -682,10 +683,11 @@ def parse_args():
help=optparse.SUPPRESS_HELP, help=optparse.SUPPRESS_HELP,
default=True, default=True,
action='store_false') action='store_false')
parser.add_option('--forward-from-humbug', parser.add_option('--no-forward-from-humbug',
default=False, default=True,
dest='forward_from_humbug',
help=optparse.SUPPRESS_HELP, help=optparse.SUPPRESS_HELP,
action='store_true') action='store_false')
parser.add_option('--verbose', parser.add_option('--verbose',
default=False, default=False,
help=optparse.SUPPRESS_HELP, help=optparse.SUPPRESS_HELP,
@ -777,6 +779,7 @@ or specify the --api-key-file option.""" % (options.api_key_file,)))
# We don't care if the child process no longer exists, so just print the error # We don't care if the child process no longer exists, so just print the error
traceback.print_exc() traceback.print_exc()
if options.forward_from_humbug:
child_pid = os.fork() child_pid = os.fork()
if child_pid == 0: if child_pid == 0:
# Run the humbug => zephyr mirror in the child # Run the humbug => zephyr mirror in the child
@ -784,6 +787,8 @@ or specify the --api-key-file option.""" % (options.api_key_file,)))
zsig_fullname = fetch_fullname(options.user) zsig_fullname = fetch_fullname(options.user)
humbug_to_zephyr(options) humbug_to_zephyr(options)
sys.exit(0) sys.exit(0)
else:
child_pid = None
import zephyr import zephyr
while True: while True: