import { CHECK_IN_PATH } from "@cocalc/util/db-schema/compute-servers";
import { webapp_client } from "@cocalc/frontend/webapp-client";
import { redux } from "@cocalc/frontend/app-framework";
export async function checkIn({
project_id,
compute_server_id,
}: {
project_id: string;
compute_server_id: number;
}) {
if (compute_server_id != null) {
await webapp_client.project_client.exec({
command: "touch",
args: [CHECK_IN_PATH],
project_id,
compute_server_id,
});
return;
}
}
export function checkInAll(project_id) {
const computeServers = redux
.getProjectStore(project_id)
.get("compute_servers");
if (computeServers == null) {
return;
}
const ids = computeServers
.filter((x) => x.get("state") == "running")
.map((x) => x.get("id"))
.keySeq();
for (const id of ids) {
(async () => {
try {
await checkIn({ project_id, compute_server_id: id });
} catch (err) {
console.warn(`checkIn issue with compute server ${id}`, err);
}
})();
}
}