diff options
author | Paul J. Davis <paul.joseph.davis@gmail.com> | 2014-02-06 16:05:47 -0600 |
---|---|---|
committer | Paul J. Davis <paul.joseph.davis@gmail.com> | 2014-02-06 16:06:59 -0600 |
commit | 49cb55177b0177c61f7eacff0e65b2be3b9082c1 (patch) | |
tree | cdf589fa61351d9cb01f5012f9d4ab09b86802cc | |
parent | dc75c75eb2ed5c46c4b76cc1bbd945c3aaa68578 (diff) | |
download | couchdb-49cb55177b0177c61f7eacff0e65b2be3b9082c1.tar.gz |
Make the process list a global in dev/run
-rwxr-xr-x | dev/run | 51 |
1 files changed, 32 insertions, 19 deletions
@@ -28,7 +28,9 @@ import urllib USAGE = "%prog [options] [command to run...]" DEV_PATH = os.path.dirname(os.path.abspath(__file__)) COUCHDB = os.path.dirname(DEV_PATH) + N = 3 +PROCESSES = [] def init_log_dir(): @@ -168,15 +170,40 @@ def connect_nodes(backdoor): sp.check_call(cmd, shell=True) +def kill_processes(): + global PROCESSES + for p in PROCESSES: + if p.returncode is None: + p.kill() + + +def boot_nodes(): + global N, PROCESSES + for i in range(1, N+1): + p = boot_node("node%d" % i) + PROCESSES.append(p) + + for i in range(30): + if all_nodes_alive(N): + break + time.sleep(1) + + +def reboot_nodes(): + kill_processes() + boot_nodes() + + def run_command(cmd): p = sp.Popen(cmd, shell=True) p.wait() exit(p.returncode) -def wait_for_procs(procs): +def wait_for_procs(): + global PROCESSES while True: - for p in procs: + for p in PROCESSES: if p.returncode is not None: exit(1) time.sleep(2) @@ -197,29 +224,15 @@ def main(): init_beams() write_configs(opts) - procs = [] - - def kill_procs(): - for p in procs: - if p.returncode is None: - p.terminate() - atexit.register(kill_procs) - - for i in range(1, 4): - p = boot_node("node%d" % i) - procs.append(p) - - for i in range(30): - if all_nodes_alive(N): - break - time.sleep(1) + atexit.register(kill_processes) + boot_nodes() connect_nodes("http://127.0.0.1:15986/") if len(args): run_command(" ".join(args)) else: - wait_for_procs(procs) + wait_for_procs() if __name__ == "__main__": |