def builder_start_cmd(args): instance = BuilderInstance.instance() if instance.status() == 'stopped': print("Starting builder instance...") instance.start() for i in range(60): if instance.status() == 'running': break time.sleep(1) else: raise RuntimeError("Unable to start instance, still in state: {}".format(instance.status())) for i in range(60): try: r = exec_remote(instance, ["echo", "hello"]) if r.strip() == "hello": break except Exception as e: print("Still waiting for SSH: got: {}".format(e)) pass time.sleep(1) else: raise RuntimeError("Unable to get SSH access") res = exec_remote(instance, ["bash", "-c", "cd compiler-explorer-image && git pull && sudo ./setup-builder.sh"]) print(res) print("Builder started OK")
def builder_start_cmd(_): instance = BuilderInstance.instance() if instance.status() == 'stopped': print("Starting builder instance...") instance.start() for _ in range(60): if instance.status() == 'running': break time.sleep(1) else: raise RuntimeError( "Unable to start instance, still in state: {}".format( instance.status())) for _ in range(60): try: r = exec_remote(instance, ["echo", "hello"]) if r.strip() == "hello": break except subprocess.CalledProcessError as e: print("Still waiting for SSH: got: {}".format(e)) time.sleep(1) else: raise RuntimeError("Unable to get SSH access") res = exec_remote(instance, [ "bash", "-c", "cd infra && git pull && sudo ./setup-builder-startup.sh" ]) print(res) print("Builder started OK")
def builder_status_cmd(args): print("Builder status: {}".format(BuilderInstance.instance().status()))
def builder_stop_cmd(args): BuilderInstance.instance().stop()
def builder_exec_cmd(args): instance = BuilderInstance.instance() exec_remote_to_stdout(instance, args['remote_cmd'])
def builder_login_cmd(args): instance = BuilderInstance.instance() run_remote_shell(args, instance)
def builder_status(): """Get the builder status (running or otherwise).""" print("Builder status: {}".format(BuilderInstance.instance().status()))
def builder_stop(): """Stop the builder instance.""" BuilderInstance.instance().stop()
def builder_exec(remote_cmd: Sequence[str]): """Execute REMOTE_CMD on the builder instance.""" instance = BuilderInstance.instance() exec_remote_to_stdout(instance, remote_cmd)
def builder_login(): """Log in to the builder machine.""" instance = BuilderInstance.instance() run_remote_shell(instance)