Path: blob/master/src/packages/util/compute-states.ts
5836 views
/*1* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45import { defineMessage } from "react-intl";67import { IntlMessage } from "./i18n/types";89// Compute related schema stuff (see compute.coffee)10//11// Here's a picture of the finite state machine defined below:12//13// ----------[closing] ------- --------- [stopping] <--------14// \|/ \|/ |15// [archived] <--> [closed] --> [opening] --> [opened] --> [starting] --> [running]16//17// [unarchiving] [pending]18// [archiving]19//20//21// The icon names below refer to font-awesome, and are used in the UI.2223export type State =24| "archived"25| "archiving"26| "closed"27| "closing"28| "opened"29| "opening"30| "pending"31| "running"32| "starting"33| "stopping"34| "unarchiving";3536// @hsy: completely unclear what this is for.37type Operation =38| "open"39| "archived"40| "unarchive"41| "start"42| "stop"43| "close"44| "closed";4546// These icon names must be a subset of the known names in frontend/componten/icon.tsx (we can't import IconName here, though)47export type ComputeStateIcon =48| "file-archive"49| "download"50| "paper-plane"51| "gears"52| "stop"53| "times-rectangle"54| "flash"55| "hand-stop"56| "run";5758export type ComputeState = {59desc: IntlMessage; // shows up in the UI (default)60desc_cocalccom?: IntlMessage; // if set, use this string instead of desc in "cocalc.com" mode61icon: ComputeStateIcon;62display: IntlMessage;63stable?: boolean;64to: { [key in Operation]?: State };65timeout?: number;66commands: Readonly<string[]>;67};6869type ComputeStates = Readonly<{70[key in State]: ComputeState;71}>;7273// ATTN: in the frontend, all "display" and "desc" strings are translated in the components/project-state file.7475export const COMPUTE_STATES: ComputeStates = {76archived: {77desc: defineMessage({78id: "util.compute-states.archived.desc",79defaultMessage:80"Project is stored in longterm storage, and will take even longer to start.",81}),82icon: "file-archive",83display: defineMessage({84id: "util.compute-states.archived.display",85defaultMessage: "Archived", // displayed name for users86}),87stable: true,88to: {89closed: "unarchiving",90},91commands: ["unarchive"],92},9394unarchiving: {95desc: defineMessage({96id: "util.compute-states.unarchiving.desc",97defaultMessage:98"Project is being copied from longterm storage; this may take several minutes depending on how many files you have.",99}),100icon: "download",101display: defineMessage({102id: "util.compute-states.unarchiving.display",103defaultMessage: "Restoring",104}),105to: {},106timeout: 30 * 60,107commands: ["status", "mintime"],108},109110archiving: {111desc: defineMessage({112id: "util.compute-states.archiving.desc",113defaultMessage: "Project is being archived to longterm storage.",114}),115icon: "paper-plane",116display: defineMessage({117id: "util.compute-states.archiving.display",118defaultMessage: "Archiving",119}),120to: {},121timeout: 5 * 60,122commands: ["status", "mintime"],123},124125closed: {126desc: defineMessage({127id: "util.compute-states.closed.desc",128defaultMessage:129"Project is archived and needs to be decompressed, so it will take longer to start.",130}),131icon: "file-archive", // font awesome icon132display: defineMessage({133id: "util.compute-states.closed.display",134defaultMessage: "Closed", // displayed name for users135}),136stable: true,137to: {138open: "opening",139archived: "archiving",140},141commands: ["open", "move", "status", "destroy", "mintime", "archive"],142},143144opening: {145desc: defineMessage({146id: "util.compute-states.opening.desc",147defaultMessage:148"Project is being imported; this may take several minutes depending on size.",149}),150icon: "gears",151display: defineMessage({152id: "util.compute-states.opening.display",153defaultMessage: "Opening",154}),155to: {},156timeout: 30 * 60,157commands: ["status", "mintime"],158},159160closing: {161desc: defineMessage({162id: "util.compute-states.closing.desc",163defaultMessage: "Project is in the process of being closed.",164}),165icon: "download",166display: defineMessage({167id: "util.compute-states.closing.display",168defaultMessage: "Closing",169}),170to: {},171timeout: 5 * 60,172commands: ["status", "mintime"],173},174175opened: {176desc: defineMessage({177id: "util.compute-states.opened.desc",178defaultMessage: "Project is available and ready to run.",179}),180icon: "stop",181display: defineMessage({182id: "util.compute-states.opened.display",183defaultMessage: "Stopped",184}),185stable: true,186to: {187start: "starting",188close: "closing",189},190commands: [191"start",192"close",193"save",194"copy_path",195"mkdir",196"directory_listing",197"read_file",198"network",199"mintime",200"disk_quota",201"compute_quota",202"status",203"migrate_live",204"ephemeral_state",205"ephemeral_disk",206],207},208209pending: {210desc_cocalccom: defineMessage({211id: "util.compute-states.pending.desc_cocalccom",212defaultMessage:213"Finding a place to run your project. If nothing becomes available, reduce RAM or CPU, pay for members only hosting, or contact support.",214}),215desc: defineMessage({216id: "util.compute-states.pending.desc",217defaultMessage:218"Finding a place to run your project. If nothing becomes available, contact your administrator.",219}),220icon: "times-rectangle",221display: defineMessage({222id: "util.compute-states.pending.display",223defaultMessage: "Pending",224}),225stable: true,226to: {227stop: "stopping",228},229commands: ["stop"],230},231232starting: {233desc: defineMessage({234id: "util.compute-states.starting.desc",235defaultMessage: "Project is starting up.",236}),237icon: "flash",238display: defineMessage({239id: "util.compute-states.starting.display",240defaultMessage: "Starting",241}),242to: {},243timeout: 60,244commands: [245"save",246"copy_path",247"mkdir",248"directory_listing",249"read_file",250"network",251"mintime",252"disk_quota",253"compute_quota",254"status",255],256},257258stopping: {259desc: defineMessage({260id: "util.compute-states.stopping.desc",261defaultMessage: "Project is stopping.",262}),263icon: "hand-stop",264display: defineMessage({265id: "util.compute-states.stopping.display",266defaultMessage: "Stopping",267}),268timeout: 60,269to: {},270commands: [271"save",272"copy_path",273"mkdir",274"directory_listing",275"read_file",276"network",277"mintime",278"disk_quota",279"compute_quota",280"status",281],282},283284running: {285desc: defineMessage({286id: "util.compute-states.running.desc",287defaultMessage: "Project is running.",288}),289icon: "run",290display: defineMessage({291id: "util.compute-states.running.display",292defaultMessage: "Running",293}),294stable: true,295to: {296stop: "stopping",297},298commands: [299"stop",300"save",301"address",302"copy_path",303"mkdir",304"directory_listing",305"read_file",306"network",307"mintime",308"disk_quota",309"compute_quota",310"status",311"migrate_live",312],313},314} as const;315316317