Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/packages/frontend/compute/auto-restart.tsx
Views: 687
import { Alert, Checkbox, Switch } from "antd";1import { useEffect, useState } from "react";2import { Icon } from "@cocalc/frontend/components/icon";3import { A } from "@cocalc/frontend/components/A";45export default function AutoRestart({ setConfig, configuration, loading }) {6const [autoRestart, setAutoRestart] = useState<boolean>(7!!configuration.autoRestart,8);9const [help, setHelp] = useState<boolean>(false);10useEffect(() => {11setAutoRestart(configuration.autoRestart);12}, [configuration]);13return (14<div>15<div style={{ color: "#666", marginBottom: "5px" }}>16<div>17<b>18<Switch19size="small"20checkedChildren={"Help"}21unCheckedChildren={"Help"}22style={{ float: "right" }}23checked={help}24onChange={(val) => setHelp(val)}25/>26<Icon name="run" /> Automatically Restart27</b>28</div>29{help && (30<Alert31showIcon32style={{ margin: "15px 0" }}33type="info"34message={"Automatically Restart Compute Server"}35description={36<div>37<p>38Select this option and CoCalc will automatically restart your39compute server if it is killed, crashes or otherwise stops40pinging CoCalc.41</p>42{!!configuration["spot"] && (43<p>44This is useful if you are running a web server on a spot45instances, since spot instances will get killed when there46is a surge of usage by other people. Your compute server may47then automatically get started somewhere else in the data48center.49</p>50)}51<p>52You can use the{" "}53<A href="https://help.ubuntu.com/community/CronHowto">54standard crontab command line tool55</A>{" "}56(which is installed and fully supported for compute servers)57to start scripts or processes running whenever your server58restarts, or to periodically run a script.59</p>60</div>61}62/>63)}64<Checkbox65style={{ marginTop: "5px" }}66disabled={loading}67checked={autoRestart}68onChange={() => {69setConfig({ autoRestart: !autoRestart });70setAutoRestart(!autoRestart);71}}72>73Automatically Restart: restart compute server if it stops responding74</Checkbox>75</div>76</div>77);78}798081