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,7 +177,8 @@ 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:
os.kill(child_pid, signal.SIGTERM) if child_pid is not None:
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
logging.exception("") logging.exception("")
@ -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,13 +779,16 @@ 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()
child_pid = os.fork() if options.forward_from_humbug:
if child_pid == 0: child_pid = os.fork()
# Run the humbug => zephyr mirror in the child if child_pid == 0:
logger = configure_logger("humbug=>zephyr") # Run the humbug => zephyr mirror in the child
zsig_fullname = fetch_fullname(options.user) logger = configure_logger("humbug=>zephyr")
humbug_to_zephyr(options) zsig_fullname = fetch_fullname(options.user)
sys.exit(0) humbug_to_zephyr(options)
sys.exit(0)
else:
child_pid = None
import zephyr import zephyr
while True: while True: