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/project/project.ts
Views: 687
/*1* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45import daemonizeProcess from "daemonize-process";67import { init as initBugCounter } from "./bug-counter";8import { init as initClient } from "./client";9import initInfoJson from "./info-json";10import initKucalc from "./init-kucalc";11import { getOptions } from "./init-program";12import { cleanup as cleanupEnvironmentVariables } from "./project-setup";13import initPublicPaths from "./public-paths";14import initServers from "./servers/init";1516import { getLogger } from "./logger";17const logger = getLogger("project-main");1819function checkEnvVariables() {20const { HOME } = process.env;21if (HOME == null) {22throw Error("HOME env var must be set");23}24process.chdir(HOME);2526if (process.env.DATA == null) {27throw Error("DATA env var must be set");28}29// TODO: some code, e.g., smc_pyutil's cc-jupyter script, assumes30// that SMC is defined still.31process.env.SMC = process.env.DATA;32}3334export async function main() {35initBugCounter();36checkEnvVariables();37const options = getOptions();38if (options.daemon) {39logger.info("daemonize the process");40daemonizeProcess();41}42cleanupEnvironmentVariables();43initKucalc(); // must be after cleanupEnvironmentVariables, since this *adds* custom environment variables.44logger.info("main init function");45logger.info("initialize INFO.json file");46await initInfoJson();47logger.info("create Client interface");48initClient();49logger.info("create all the servers...");50await initServers();51logger.info("create public paths watcher...");52initPublicPaths();53}545556