Path: blob/master/src/packages/frontend/compute/check-in.ts
1503 views
import { CHECK_IN_PATH } from "@cocalc/util/db-schema/compute-servers";1import { webapp_client } from "@cocalc/frontend/webapp-client";2import { redux } from "@cocalc/frontend/app-framework";34// cause the given compute server to check in, or all running compute5// servers in the project if compute_server_id isn't specified.6export async function checkIn({7project_id,8compute_server_id,9}: {10project_id: string;11compute_server_id: number;12}) {13if (compute_server_id != null) {14await webapp_client.project_client.exec({15command: "touch",16args: [CHECK_IN_PATH],17project_id,18compute_server_id,19});20return;21}22}2324// launches in parallel check in on all running projects; doesn't25// wait for response.26export function checkInAll(project_id) {27const computeServers = redux28.getProjectStore(project_id)29.get("compute_servers");30if (computeServers == null) {31return;32}33const ids = computeServers34.filter((x) => x.get("state") == "running")35.map((x) => x.get("id"))36.keySeq();37for (const id of ids) {38(async () => {39try {40await checkIn({ project_id, compute_server_id: id });41} catch (err) {42console.warn(`checkIn issue with compute server ${id}`, err);43}44})();45}46}474849