[{"data":1,"prerenderedAt":385,"buildId":386},["ShallowReactive",2],{"docs:\u002Fguide\u002Fplacement":3},{"page":4,"section":16,"document":17,"credits":10,"prev":377,"next":381},{"id":5,"path":6,"file":7,"title":8,"sourceTitle":8,"description":9,"tagline":9,"eyebrow":10,"credits":10,"keywords":11,"icon":12,"layout":13,"sidebar":14,"toc":14,"kind":10,"group":10,"navigation":14,"order":15},"placement","\u002Fguide\u002Fplacement","guide\u002Fplacement.md","How jobs are placed","How fleetjobs decides where a queued job runs, which jobs may leave this machine, and what the local machine's rules allow.",null,[],"i-lucide-git-fork","article",true,3,"guide",{"nodes":18,"toc":369},[19,32,40,47,101,108,133,139,150,156,159,281,287,293,304,307,324,330,348,354],[20,21,22,23,27,28,31],"p",{},"Every job starts as a record in the store and a supervisor process of its own. The supervisor asks the scheduler where the job should run, waits for that place to have room, then runs the job there. The scheduler is a pure function, ",[24,25,26],"code",{},"schedule(state, policy)",", in the ",[24,29,30],{},"fleetjobs\u002Fschedule"," entry. It reads the queue, this machine's state and each host's state, and returns one decision for each queued job: start in a place, or wait.",[33,34,39],"h2",{"id":35,"anchor":36},"lanes-and-slots",{"label":37,"icon":38},"Section titled \"Lanes and slots\"","#","Lanes and slots",[20,41,42,43,46],{},"A job waits in one of two lanes. The heavy lane is the default. The light lane, chosen with ",[24,44,45],{},"--light",", is for quick commands such as lint or one test file.",[48,49,50,69],"table",{},[51,52,53],"thead",{},[54,55,56,60,63,66],"tr",{},[57,58,59],"th",{},"Lane",[57,61,62],{},"Slots on this machine",[57,64,65],{},"Memory free before a job starts",[57,67,68],{},"Time limit",[70,71,72,87],"tbody",{},[54,73,74,78,81,84],{},[75,76,77],"td",{},"heavy",[75,79,80],{},"2, a third while the machine is idle",[75,82,83],{},"4 GB",[75,85,86],{},"1200 s",[54,88,89,92,95,98],{},[75,90,91],{},"light",[75,93,94],{},"1, a second while CPU pressure is low",[75,96,97],{},"2 GB",[75,99,100],{},"300 s",[20,102,103,104,107],{},"The machine counts as idle for the third heavy slot while tasks wait for a CPU under 10% of the time, wait for disk under 25% of the time, and 8 GB are free. The second light slot opens while CPU pressure is under 20% and 4 GB are free. fleetjobs reads pressure stall information from ",[24,105,106],{},"\u002Fproc\u002Fpressure",", because the load average counts processes that wait on disk. Without it, the extra slots stay closed.",[20,109,110,111,114,115,120,121,124,125,128,129,132],{},"The slot counts come from the ",[24,112,113],{},"local"," block of ",[116,117,119],"a",{"href":118},"\u002Freference\u002Fconfig","the config file",". A job over its time limit gets ",[24,122,123],{},"TERM",", then ",[24,126,127],{},"KILL"," 30 seconds later. Raise the limit with ",[24,130,131],{},"HEAVY_MAX",".",[33,134,138],{"id":135,"anchor":136},"order",{"label":137,"icon":38},"Section titled \"Order\"","Order",[20,140,141,142,145,146,149],{},"Light jobs are placed before heavy ones. Within a lane the scheduler ranks each job by a score, and the lowest goes first. The score is the checkout's usage, plus the seconds its jobs hold a heavy slot now, minus the seconds this job has waited. A checkout is the nearest folder up that holds ",[24,143,144],{},".git",", and its usage is the slot seconds its heavy jobs used here lately, halved every 30 minutes. So a session that used little goes first, and waiting lowers the score. A short job, whose last runs took 30 seconds or less, starts 10 minutes ahead. A job that goes back to run here after a remote result, class ",[24,147,148],{},"confirm",", goes before everything.",[33,151,155],{"id":152,"anchor":153},"which-jobs-may-leave",{"label":154,"icon":38},"Section titled \"Which jobs may leave\"","Which jobs may leave",[20,157,158],{},"A job may run on a host only when all of these hold:",[160,161,162,166,175,178,216,227,233,268],"ul",{},[163,164,165],"li",{},"It is in the heavy lane.",[163,167,168,171,172,132],{},[24,169,170],{},"HEAVY_LOCAL"," is not ",[24,173,174],{},"1",[163,176,177],{},"The config lists at least one host.",[163,179,180,181,184,185,184,188,191,192,195,196,199,200,184,203,184,206,191,209,212,213,215],{},"Its command is a build, test, typecheck or lint, such as ",[24,182,183],{},"pnpm test",", ",[24,186,187],{},"vitest",[24,189,190],{},"tsc"," or ",[24,193,194],{},"pnpm build",". ",[24,197,198],{},"HEAVY_REMOTE=1"," lifts this for any command. A command with a word that installs, deploys, serves or drives a browser, such as ",[24,201,202],{},"install",[24,204,205],{},"dev",[24,207,208],{},"docker",[24,210,211],{},"wrangler",", stays here unless ",[24,214,198],{}," is set.",[163,217,218,219,222,223,226],{},"It runs inside a git checkout whose ",[24,220,221],{},"origin"," is not matched by a ",[24,224,225],{},"never"," pattern in the config.",[163,228,229,230,132],{},"No argument names a path outside the checkout or under ",[24,231,232],{},"\u002Ftmp",[163,234,235,236,184,239,184,242,191,245,248,249,184,252,255,256,259,260,263,264,267],{},"No ",[24,237,238],{},".env",[24,240,241],{},".env.*",[24,243,244],{},".dev.vars",[24,246,247],{},".pem"," file is within four levels of the checkout's root, other than ",[24,250,251],{},".example",[24,253,254],{},".sample"," and ",[24,257,258],{},".template"," files, and ",[24,261,262],{},".npmrc"," holds no ",[24,265,266],{},"_auth"," line.",[163,269,270,271,191,274,277,278,280],{},"The checkout has a ",[24,272,273],{},"pnpm-lock.yaml",[24,275,276],{},"package-lock.json"," to install from. With ",[24,279,198],{},", a checkout with neither is also allowed.",[20,282,283,284,286],{},"A job that fails any of these runs here, and ",[24,285,77],{}," says why on stderr.",[33,288,292],{"id":289,"anchor":290},"where-it-runs",{"label":291,"icon":38},"Section titled \"Where it runs\"","Where it runs",[20,294,295,296,299,300,303],{},"The ",[24,297,298],{},"default"," policy lets each job, in score order, take the place where it finishes first. For a slot here, that is when the slot frees plus the job's estimate, taken from its last runs. For a slot on a host, it is when the slot frees, plus the time to copy the checkout, plus the estimate divided by the host's ",[24,301,302],{},"speed",". When that place is busy, the job waits for it and holds it, so a later job cannot take it first, and a later job may still start at once somewhere else. A host that is down, short of memory or disk, or busy with other work takes no jobs.",[20,305,306],{},"Hosts are probed over ssh at most every 15 seconds, and every 2 minutes while one is down. A host that refuses a job rests for a minute, and the job goes back to the queue here.",[20,308,295,309,312,313,315,316,319,320,132],{},[24,310,311],{},"bash"," policy follows the rules the old bash ",[24,314,77],{}," logged, and exists so ",[24,317,318],{},"heavy replay"," can compare the two. See ",[116,321,323],{"href":322},"\u002Freference\u002Fcli#heavy-replay","replay",[33,325,329],{"id":326,"anchor":327},"dev-servers-and-watchers",{"label":328,"icon":38},"Section titled \"Dev servers and watchers\"","Dev servers and watchers",[20,331,332,333,184,335,184,338,184,341,191,344,347],{},"A command with ",[24,334,205],{},[24,336,337],{},"serve",[24,339,340],{},"preview",[24,342,343],{},"start",[24,345,346],{},"watch"," in it holds memory, not CPU, and would keep a slot for its whole life. It runs at once, outside the queue, under the same time limit.",[33,349,353],{"id":350,"anchor":351},"when-memory-runs-out",{"label":352,"icon":38},"Section titled \"When memory runs out\"","When memory runs out",[20,355,356,357,360,361,364,365,132],{},"Each job runs in its own systemd scope under the slice ",[24,358,359],{},"HEAVY_SLICE",", so the kernel's out-of-memory killer picks the job and not your session. A job that the kernel kills exits with 137. fleetjobs waits up to ",[24,362,363],{},"HEAVY_OOM_WAIT"," seconds for the job's peak memory plus 2 GB to be free, then retries it once. A second kill queues the job for the ",[116,366,368],{"href":367},"\u002Fguide\u002Fnight","night queue",[370,372,373,374,375,376],{"id":35,"depth":371,"text":39},2,{"id":135,"depth":371,"text":138},{"id":152,"depth":371,"text":155},{"id":289,"depth":371,"text":292},{"id":326,"depth":371,"text":329},{"id":350,"depth":371,"text":353},{"path":378,"title":379,"description":380},"\u002Fguide\u002Finstallation","Installation","Install fleetjobs with your package manager, then run a first command through the heavy queue and check its job.",{"path":382,"title":383,"description":384},"\u002Fguide\u002Fhosts","Remote hosts","Set up a host that runs your jobs over ssh, with the tools it needs, the config entry, and how the checkout is copied and checked.",1796530822098,"9e7c308e-a25b-413c-bd8b-9a1122ddc1d4"]