gristlabs_grist-core/stubs/app/server/server.ts
Paul Fitzpatrick 5ef889addd (core) move home server into core
Summary: This moves enough server material into core to run a home server.  The data engine is not yet incorporated (though in manual testing it works when ported).

Test Plan: existing tests pass

Reviewers: dsagal

Reviewed By: dsagal

Differential Revision: https://phab.getgrist.com/D2552
2020-07-21 20:39:10 -04:00

26 lines
814 B
TypeScript

import {updateDb} from 'app/server/lib/dbUtils';
import {main as mergedServerMain} from 'app/server/mergedServerMain';
import * as fse from 'fs-extra';
const G = {
port: parseInt(process.env.PORT!, 10) || 8484,
};
export async function main() {
// Use a distinct cookie.
if (!process.env.GRIST_SESSION_COOKIE) {
process.env.GRIST_SESSION_COOKIE = 'grist_core';
}
// This is where documents are placed, for historic reasons.
await fse.mkdirp('samples');
// Make a blank db if needed.
await updateDb();
// Launch single-port, self-contained version of Grist.
// You probably want to have GRIST_DEFAULT_EMAIL set since there's no login system yet.
await mergedServerMain(G.port, ["home", "docs", "static"]);
}
if (require.main === module) {
main().catch((err) => console.error(err));
}