morca · API

orca.pool

An EC2 instance's side of the warm pool (orca.ec2, ORCA_EC2_POOL_SECONDS): the two commands its script runs between runs, through the pipeline's binary, over ORCA_DATABASE_URL.

<binary> pool-wait <instance> <run> <start>             a worker: until its run is over
<binary> pool-next <instance> <run> <start> <seconds>   until it's handed another run

The scheduler hands an idle instance to a run by ending its row in orca.instances and inserting one for the new run, pooled, in one transaction. So the instance learns of its next run from its own rows, and Postgres, which every instance reaches already, is the only channel: no other service, port or permission. pool-next marks the row of the run the instance served idle (its work has stopped: the head's driver and dista head have exited, a worker's processes are killed), and beats polled every second, which the scheduler checks before it hands the instance out. When a new row appears, it records that it joined, prints next <run> <start> <head address> <0|1> (the last, whether the run may use new code) and exits 0; when its row ends with no other (the scheduler shut the idle instance down), or seconds and a minute more pass, it exits 1 and the script shuts the instance down.

pool-wait, beside a worker's processes, exits 0 once the run isn't running at that start any more, or the worker's row has ended: dista workers don't end with their head, so this is how a worker knows to stop. Both ride out a database that can't be reached for a while, retrying every second.

Functions

pool_wait_main

def pool_wait_main(args: List[String]) -> Int

pool-wait <instance> <run> <start>: returns once the run is over for the instance.

pool_next_main

def pool_next_main(args: List[String]) -> Int

pool-next <instance> <run> <start> <seconds>: waits, idle, for the run the scheduler hands the instance; see the module's doc.

getenv_url

def getenv_url() -> String