[{"data":1,"prerenderedAt":625,"buildId":626},["ShallowReactive",2],{"docs:\u002Freference\u002Fapi":3},{"page":4,"section":16,"document":17,"credits":10,"prev":618,"next":622},{"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},"api","\u002Freference\u002Fapi","reference\u002Fapi.md","Library API","The functions and types fleetjobs exports for queueing jobs from a program, scheduling them, replaying logs and reading the job record.",null,[],"i-lucide-braces","article",true,4,"reference",{"nodes":18,"toc":607},[19,36,44,135,144,151,254,262,277,285,292,300,303,310,351,480,523,554,561],[20,21,22,23,27,28,31,32,35],"p",{},"Three entries: ",[24,25,26],"code",{},"fleetjobs"," queues and follows jobs, ",[24,29,30],{},"fleetjobs\u002Fschedule"," holds the scheduler and the replay, and ",[24,33,34],{},"fleetjobs\u002Fschema"," holds the types. All are ES modules for Node 22.20 or later.",[37,38,42],"h2",{"id":26,"anchor":39},{"label":40,"icon":41},"Section titled \"fleetjobs\"","#",[24,43,26],{},[45,46,49],"pre",{"language":47,"class":48,"wrap":14},"ts","shiki shiki-themes github-light-default github-dark-default dark:github-dark-default",[24,50,52,75,76,75,78,75,118],{"class":51},"language-ts",[53,54,57,61,65,68,72],"span",{"class":55,"style":56},"line","display: inline",[53,58,60],{"style":59},"color:#CF222E;--shiki-dark:#FF7B72","import",[53,62,64],{"style":63},"color:#1F2328;--shiki-dark:#E6EDF3"," { cancel, status, submit, wait } ",[53,66,67],{"style":59},"from",[53,69,71],{"style":70},"color:#0A3069;--shiki-dark:#A5D6FF"," \"fleetjobs\"",[53,73,74],{"style":63},";","\n",[53,77],{"class":55,"style":56},[53,79,80,83,87,90,93,97,100,103,106,109,112,115],{"class":55,"style":56},[53,81,82],{"style":59},"const",[53,84,86],{"style":85},"color:#0550AE;--shiki-dark:#79C0FF"," id",[53,88,89],{"style":59}," =",[53,91,92],{"style":59}," await",[53,94,96],{"style":95},"color:#8250DF;--shiki-dark:#D2A8FF"," submit",[53,98,99],{"style":63},"([",[53,101,102],{"style":70},"\"pnpm\"",[53,104,105],{"style":63},", ",[53,107,108],{"style":70},"\"test\"",[53,110,111],{"style":63},"], { lane: ",[53,113,114],{"style":70},"\"heavy\"",[53,116,117],{"style":63}," });",[53,119,120,122,125,127,129,132],{"class":55,"style":56},[53,121,82],{"style":59},[53,123,124],{"style":85}," exit",[53,126,89],{"style":59},[53,128,92],{"style":59},[53,130,131],{"style":95}," wait",[53,133,134],{"style":63},"(id, { output: { stdout: write, stderr: write } });",[136,137,141],"h3",{"id":138,"anchor":139},"submitargv-options",{"label":140,"icon":41},"Section titled \"submit(argv, options?)\"",[24,142,143],{},"submit(argv, options?)",[20,145,146,147,150],{},"Queues a command and returns the job id as a string. While a job with the same working directory and ",[24,148,149],{},"argv"," is queued or running, it returns that job's id and starts nothing.",[152,153,154,170],"table",{},[155,156,157],"thead",{},[158,159,160,164,167],"tr",{},[161,162,163],"th",{},"Option",[161,165,166],{},"Default",[161,168,169],{},"Meaning",[171,172,173,189,208,239],"tbody",{},[158,174,175,181,186],{},[176,177,178],"td",{},[24,179,180],{},"cwd",[176,182,183],{},[24,184,185],{},"process.cwd()",[176,187,188],{},"The working directory",[158,190,191,196,200],{},[176,192,193],{},[24,194,195],{},"lane",[176,197,198],{},[24,199,114],{},[176,201,202,204,205],{},[24,203,114],{}," or ",[24,206,207],{},"\"light\"",[158,209,210,215,229],{},[176,211,212],{},[24,213,214],{},"remote",[176,216,217,218,221,222,225,226],{},"from ",[24,219,220],{},"HEAVY_LOCAL"," and ",[24,223,224],{},"HEAVY_REMOTE",", else ",[24,227,228],{},"\"auto\"",[176,230,231,105,233,204,236],{},[24,232,228],{},[24,234,235],{},"\"any\"",[24,237,238],{},"\"never\"",[158,240,241,246,251],{},[176,242,243],{},[24,244,245],{},"blocking",[176,247,248],{},[24,249,250],{},"false",[176,252,253],{},"The caller waits for the job, so it leaves the queue after 10 minutes without a waiter, not 60",[136,255,259],{"id":256,"anchor":257},"waitid-options",{"label":258,"icon":41},"Section titled \"wait(id, options?)\"",[24,260,261],{},"wait(id, options?)",[20,263,264,265,268,269,272,273,276],{},"Resolves with the job's exit code once it is done. ",[24,266,267],{},"options.output"," is ",[24,270,271],{},"{ stdout, stderr }",", two functions that receive each chunk of the job's output as a ",[24,274,275],{},"Uint8Array",", from the start of the job. It rejects when the id names no job, and when the job's supervisor died before the job ended.",[136,278,282],{"id":279,"anchor":280},"status",{"label":281,"icon":41},"Section titled \"status()\"",[24,283,284],{},"status()",[20,286,287,288,291],{},"Resolves with a ",[24,289,290],{},"Job[]",": the jobs that are queued or running, and the ones that ended in the last 10 minutes, oldest first.",[136,293,297],{"id":294,"anchor":295},"cancelid",{"label":296,"icon":41},"Section titled \"cancel(id)\"",[24,298,299],{},"cancel(id)",[20,301,302],{},"Stops the job and resolves once its record is done. It does nothing for a job that already ended, and rejects for an unknown id.",[37,304,308],{"id":305,"anchor":306},"fleetjobsschedule",{"label":307,"icon":41},"Section titled \"fleetjobs\u002Fschedule\"",[24,309,30],{},[45,311,312],{"language":47,"class":48,"wrap":14},[24,313,314,75,328,75,330],{"class":51},[53,315,316,318,321,323,326],{"class":55,"style":56},[53,317,60],{"style":59},[53,319,320],{"style":63}," { schedule } ",[53,322,67],{"style":59},[53,324,325],{"style":70}," \"fleetjobs\u002Fschedule\"",[53,327,74],{"style":63},[53,329],{"class":55,"style":56},[53,331,332,334,337,339,342,345,348],{"class":55,"style":56},[53,333,82],{"style":59},[53,335,336],{"style":85}," decisions",[53,338,89],{"style":59},[53,340,341],{"style":95}," schedule",[53,343,344],{"style":63},"(state, ",[53,346,347],{"style":70},"\"default\"",[53,349,350],{"style":63},");",[152,352,353,363],{},[155,354,355],{},[158,356,357,360],{},[161,358,359],{},"Export",[161,361,362],{},"What it is",[171,364,365,388,401,422,434,451,467],{},[158,366,367,372],{},[176,368,369],{},[24,370,371],{},"schedule(state, policy)",[176,373,374,375,221,378,204,381,383,384,387],{},"Pure. Takes a ",[24,376,377],{},"QueueState",[24,379,380],{},"\"bash\"",[24,382,347],{}," and returns one ",[24,385,386],{},"Decision"," for each queued job",[158,389,390,398],{},[176,391,392,105,395],{},[24,393,394],{},"SLOTS",[24,396,397],{},"HALF_LIFE",[176,399,400],{},"The local slot names, and the half-life of the usage count in seconds",[158,402,403,408],{},[176,404,405],{},[24,406,407],{},"replay(logs, options)",[176,409,410,411,414,415,418,419],{},"Runs the scheduler over ",[24,412,413],{},"Logs"," and returns a ",[24,416,417],{},"ReplayReport",", schema ",[24,420,421],{},"fleetjobs\u002Freplay@1",[158,423,424,429],{},[176,425,426],{},[24,427,428],{},"REPLAY_SCHEMA",[176,430,431],{},[24,432,433],{},"\"fleetjobs\u002Freplay@1\"",[158,435,436,444],{},[176,437,438,105,441],{},[24,439,440],{},"readLogs(files)",[24,442,443],{},"defaultLogFiles()",[176,445,446,447,450],{},"Read log files, and list the ones ",[24,448,449],{},"heavy replay"," reads by default",[158,452,453,461],{},[176,454,455,105,458],{},[24,456,457],{},"parseText(text, file)",[24,459,460],{},"parseJobs(text, file)",[176,462,463,464],{},"Parse the bash heavy's text log, and ",[24,465,466],{},"log\u002Fjobs.jsonl",[158,468,469,474],{},[176,470,471],{},[24,472,473],{},"emptyLogs()",[176,475,476,477,479],{},"An empty ",[24,478,413],{}," to parse into",[20,481,482,268,485,488,489,221,491,494,495,221,498,501,502,505,506,105,509,105,512,221,515,518,519,522],{},[24,483,484],{},"ReplayOptions",[24,486,487],{},"{ policy, from?, to?, hosts? }",", where ",[24,490,67],{},[24,492,493],{},"to"," are ",[24,496,497],{},"YYYY-MM-DD",[24,499,500],{},"hosts"," is a list of ",[24,503,504],{},"{ name, slots }",". The report holds ",[24,507,508],{},"parsed",[24,510,511],{},"assumptions",[24,513,514],{},"lanes",[24,516,517],{},"days","; run ",[24,520,521],{},"heavy replay --json"," to see one.",[20,524,525,528,529,532,533,268,535,538,539,542,543,546,547,488,550,553],{},[24,526,527],{},"schedule"," reads no clock, disk or network: it uses ",[24,530,531],{},"state.now",". A ",[24,534,386],{},[24,536,537],{},"{ id, start, slot?, finishAt? }"," to start a job in ",[24,540,541],{},"start",", which is ",[24,544,545],{},"\"local\""," or a host name, or ",[24,548,549],{},"{ id, wait }",[24,551,552],{},"wait"," says why the job waits.",[37,555,559],{"id":556,"anchor":557},"fleetjobsschema",{"label":558,"icon":41},"Section titled \"fleetjobs\u002Fschema\"",[24,560,34],{},[20,562,563,564,567,568,571,572,105,575,105,577,105,579,105,582,105,585,105,588,105,591,221,594,597,598,600,601,606],{},"Types and one constant: ",[24,565,566],{},"JOB_SCHEMA",", the string ",[24,569,570],{},"\"fleetjobs\u002Fjob@1\"",". The types are ",[24,573,574],{},"Job",[24,576,377],{},[24,578,386],{},[24,580,581],{},"Policy",[24,583,584],{},"Host",[24,586,587],{},"Mirror",[24,589,590],{},"Sinks",[24,592,593],{},"Transport",[24,595,596],{},"TrustEntry",". The ",[24,599,574],{}," fields are in ",[602,603,605],"a",{"href":604},"\u002Freference\u002Fjob","the job record",".",[608,616,617],{"id":26,"depth":609,"text":26,"children":610},2,[611,613,614,615],{"id":138,"depth":612,"text":143},3,{"id":256,"depth":612,"text":261},{"id":279,"depth":612,"text":284},{"id":294,"depth":612,"text":299},{"id":305,"depth":609,"text":30},{"id":556,"depth":609,"text":34},{"path":619,"title":620,"description":621},"\u002Freference\u002Fenvironment","Environment variables","Every environment variable fleetjobs reads, for time limits, placement, the store, systemd scopes, memory retries and the night run.",{"path":604,"title":623,"description":624},"Job record","The fields of the fleetjobs\u002Fjob@1 record that heavy status prints and the store keeps for every job, and the files of the store.",1796530822382,"9e7c308e-a25b-413c-bd8b-9a1122ddc1d4"]