def runner_start(): """Start the runner instance.""" instance = RunnerInstance.instance() if instance.status() == 'stopped': print("Starting runner instance...") instance.start() for _ in range(60): if instance.status() == 'running': break time.sleep(5) 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 Exception as e: # pylint: disable=broad-except print("Still waiting for SSH: got: {}".format(e)) time.sleep(5) else: raise RuntimeError("Unable to get SSH access") print("Runner started OK")
def runner_uploaddiscovery(environment: str, version: str): """Execute compiler discovery on the builder instance.""" localtemppath = f'/tmp/{version}.json' if environment == 'prod': s3path = f's3://compiler-explorer/dist/discovery/release/{version}.json' else: s3path = f's3://compiler-explorer/dist/discovery/{environment}/{version}.json' instance = RunnerInstance.instance() get_remote_file(instance, '/home/ce/discovered-compilers.json', localtemppath) os.system( f'aws s3 cp --storage-class REDUCED_REDUNDANCY --acl public-read "{localtemppath}" "{s3path}"' ) os.remove(localtemppath)
def runner_discovery(): """Execute compiler discovery on the builder instance.""" instance = RunnerInstance.instance() exec_remote_to_stdout( instance, ['bash', '-c', 'cd /infra && sudo /infra/init/do-discovery.sh'])
def runner_pull(): """Execute git pull on the builder instance.""" instance = RunnerInstance.instance() exec_remote_to_stdout(instance, ['bash', '-c', 'cd /infra && sudo git pull'])
def runner_exec(remote_cmd: Sequence[str]): """Execute REMOTE_CMD on the builder instance.""" instance = RunnerInstance.instance() exec_remote_to_stdout(instance, remote_cmd)
def runner_login(): """Log in to the runner machine.""" instance = RunnerInstance.instance() run_remote_shell(instance)
def runner_status(): """Get the runner status (running or otherwise).""" print("Runner status: {}".format(RunnerInstance.instance().status()))
def runner_stop(): """Stop the runner instance.""" RunnerInstance.instance().stop()