//native
type Fly = {
token: string;
};
/**
* Cordon Machine
* “Cordoning” a Machine refers to disabling its services, so the Fly Proxy won’t route requests to it. In flyctl this is used by blue/green deployments; one set of Machines is started up with services disabled, and when they are all healthy, the services are enabled on the new Machines and disabled on the old ones.
*/
export async function main(auth: Fly, app_name: string, machine_id: string) {
const url = new URL(
`https://api.machines.dev/v1/apps/${app_name}/machines/${machine_id}/cordon`,
);
const response = await fetch(url, {
method: "POST",
headers: {
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 235 days ago