mirror of
https://github.com/gristlabs/grist-core.git
synced 2024-10-27 20:44:07 +00:00
(core) resolved some divergence in mergedServerMain
This commit is contained in:
commit
2c7ad727d1
@ -1132,7 +1132,6 @@ export class FlexServer implements GristServer {
|
|||||||
await this.loadConfig();
|
await this.loadConfig();
|
||||||
this.addComm();
|
this.addComm();
|
||||||
|
|
||||||
await this.create.configure?.();
|
|
||||||
if (!isSingleUserMode()) {
|
if (!isSingleUserMode()) {
|
||||||
const externalStorage = appSettings.section('externalStorage');
|
const externalStorage = appSettings.section('externalStorage');
|
||||||
const haveExternalStorage = Object.values(externalStorage.nested)
|
const haveExternalStorage = Object.values(externalStorage.nested)
|
||||||
@ -1143,6 +1142,7 @@ export class FlexServer implements GristServer {
|
|||||||
this._disableExternalStorage = true;
|
this._disableExternalStorage = true;
|
||||||
externalStorage.flag('active').set(false);
|
externalStorage.flag('active').set(false);
|
||||||
}
|
}
|
||||||
|
await this.create.configure?.();
|
||||||
const workers = this._docWorkerMap;
|
const workers = this._docWorkerMap;
|
||||||
const docWorkerId = await this._addSelfAsWorker(workers);
|
const docWorkerId = await this._addSelfAsWorker(workers);
|
||||||
|
|
||||||
|
@ -50,6 +50,7 @@ export interface ICreateActiveDocOptions {
|
|||||||
export interface ICreateStorageOptions {
|
export interface ICreateStorageOptions {
|
||||||
name: string;
|
name: string;
|
||||||
check(): boolean;
|
check(): boolean;
|
||||||
|
checkBackend?(): Promise<void>;
|
||||||
create(purpose: 'doc'|'meta', extraPrefix: string): ExternalStorage|undefined;
|
create(purpose: 'doc'|'meta', extraPrefix: string): ExternalStorage|undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,7 +120,10 @@ export function makeSimpleCreator(opts: {
|
|||||||
},
|
},
|
||||||
async configure() {
|
async configure() {
|
||||||
for (const s of storage || []) {
|
for (const s of storage || []) {
|
||||||
if (s.check()) { break; }
|
if (s.check()) {
|
||||||
|
await s.checkBackend?.();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
...(opts.shell && {
|
...(opts.shell && {
|
||||||
|
@ -107,6 +107,11 @@ export class MinIOExternalStorage implements ExternalStorage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async hasVersioning(): Promise<Boolean> {
|
||||||
|
const versioning = await this._s3.getBucketVersioning(this.bucket);
|
||||||
|
return versioning && versioning.Status === 'Enabled';
|
||||||
|
}
|
||||||
|
|
||||||
public async versions(key: string, options?: { includeDeleteMarkers?: boolean }) {
|
public async versions(key: string, options?: { includeDeleteMarkers?: boolean }) {
|
||||||
const results: minio.BucketItem[] = [];
|
const results: minio.BucketItem[] = [];
|
||||||
await new Promise((resolve, reject) => {
|
await new Promise((resolve, reject) => {
|
||||||
|
@ -60,3 +60,16 @@ export function checkMinIOExternalStorage() {
|
|||||||
region
|
region
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function checkMinIOBucket() {
|
||||||
|
const options = checkMinIOExternalStorage();
|
||||||
|
if (!options) {
|
||||||
|
throw new Error('Configuration check failed for MinIO backend storage.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const externalStorage = new MinIOExternalStorage(options.bucket, options);
|
||||||
|
if (!await externalStorage.hasVersioning()) {
|
||||||
|
await externalStorage.close();
|
||||||
|
throw new Error(`FATAL: the MinIO bucket "${options.bucket}" does not have versioning enabled`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -106,6 +106,7 @@ export async function main(port: number, serverTypes: ServerType[],
|
|||||||
server.addApiMiddleware();
|
server.addApiMiddleware();
|
||||||
await server.addBillingMiddleware();
|
await server.addBillingMiddleware();
|
||||||
|
|
||||||
|
try {
|
||||||
await server.start();
|
await server.start();
|
||||||
|
|
||||||
if (includeHome) {
|
if (includeHome) {
|
||||||
@ -145,6 +146,10 @@ export async function main(port: number, serverTypes: ServerType[],
|
|||||||
server.checkOptionCombinations();
|
server.checkOptionCombinations();
|
||||||
server.summary();
|
server.summary();
|
||||||
return server;
|
return server;
|
||||||
|
} catch(e) {
|
||||||
|
await server.close();
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
12
package.json
12
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "grist-core",
|
"name": "grist-core",
|
||||||
"version": "1.1.1",
|
"version": "1.1.2",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"description": "Grist is the evolution of spreadsheets",
|
"description": "Grist is the evolution of spreadsheets",
|
||||||
"homepage": "https://github.com/gristlabs/grist-core",
|
"homepage": "https://github.com/gristlabs/grist-core",
|
||||||
@ -13,8 +13,8 @@
|
|||||||
"install:python3": "buildtools/prepare_python3.sh",
|
"install:python3": "buildtools/prepare_python3.sh",
|
||||||
"build:prod": "buildtools/build.sh",
|
"build:prod": "buildtools/build.sh",
|
||||||
"start:prod": "sandbox/run.sh",
|
"start:prod": "sandbox/run.sh",
|
||||||
"test": "GRIST_SESSION_COOKIE=grist_test_cookie GRIST_TEST_LOGIN=1 TEST_SUPPORT_API_KEY=api_key_for_support TEST_CLEAN_DATABASE=true mocha ${DEBUG:+-b --no-exit} --slow 8000 ${DEBUG:---forbid-only} -g \"${GREP_TESTS}\" '_build/test/common/*.js' '_build/test/client/*.js' '_build/test/nbrowser/*.js' '_build/test/server/**/*.js' '_build/test/gen-server/**/*.js'",
|
"test": "GRIST_SESSION_COOKIE=grist_test_cookie GRIST_TEST_LOGIN=1 TEST_SUPPORT_API_KEY=api_key_for_support TEST_CLEAN_DATABASE=true mocha ${DEBUG:+-b --no-exit} --slow 8000 $([ -z $DEBUG ] && echo --forbid-only) -g \"${GREP_TESTS}\" '_build/test/common/*.js' '_build/test/client/*.js' '_build/test/nbrowser/*.js' '_build/test/server/**/*.js' '_build/test/gen-server/**/*.js'",
|
||||||
"test:nbrowser": "TEST_SUITE=nbrowser TEST_SUITE_FOR_TIMINGS=nbrowser TIMINGS_FILE=test/timings/nbrowser.txt GRIST_SESSION_COOKIE=grist_test_cookie GRIST_TEST_LOGIN=1 TEST_SUPPORT_API_KEY=api_key_for_support TEST_CLEAN_DATABASE=true mocha ${DEBUG:+-b --no-exit} ${DEBUG:---forbid-only} -g \"${GREP_TESTS}\" --slow 8000 -R test/xunit-file '_build/test/nbrowser/**/*.js'",
|
"test:nbrowser": "TEST_SUITE=nbrowser TEST_SUITE_FOR_TIMINGS=nbrowser TIMINGS_FILE=test/timings/nbrowser.txt GRIST_SESSION_COOKIE=grist_test_cookie GRIST_TEST_LOGIN=1 TEST_SUPPORT_API_KEY=api_key_for_support TEST_CLEAN_DATABASE=true mocha ${DEBUG:+-b --no-exit} $([ -z $DEBUG ] && echo --forbid-only) -g \"${GREP_TESTS}\" --slow 8000 -R test/xunit-file '_build/test/nbrowser/**/*.js'",
|
||||||
"test:client": "GRIST_SESSION_COOKIE=grist_test_cookie mocha ${DEBUG:+'-b'} '_build/test/client/**/*.js'",
|
"test:client": "GRIST_SESSION_COOKIE=grist_test_cookie mocha ${DEBUG:+'-b'} '_build/test/client/**/*.js'",
|
||||||
"test:common": "GRIST_SESSION_COOKIE=grist_test_cookie mocha ${DEBUG:+'-b'} '_build/test/common/**/*.js'",
|
"test:common": "GRIST_SESSION_COOKIE=grist_test_cookie mocha ${DEBUG:+'-b'} '_build/test/common/**/*.js'",
|
||||||
"test:server": "TEST_SUITE=server TEST_SUITE_FOR_TIMINGS=server TIMINGS_FILE=test/timings/server.txt GRIST_SESSION_COOKIE=grist_test_cookie mocha ${DEBUG:+'-b'} -R test/xunit-file '_build/test/server/**/*.js' '_build/test/gen-server/**/*.js'",
|
"test:server": "TEST_SUITE=server TEST_SUITE_FOR_TIMINGS=server TIMINGS_FILE=test/timings/server.txt GRIST_SESSION_COOKIE=grist_test_cookie mocha ${DEBUG:+'-b'} -R test/xunit-file '_build/test/server/**/*.js' '_build/test/gen-server/**/*.js'",
|
||||||
@ -190,11 +190,13 @@
|
|||||||
"@gristlabs/sqlite3": "5.1.4-grist.8"
|
"@gristlabs/sqlite3": "5.1.4-grist.8"
|
||||||
},
|
},
|
||||||
"mocha": {
|
"mocha": {
|
||||||
"require": ["test/setupPaths",
|
"require": [
|
||||||
|
"test/setupPaths",
|
||||||
"source-map-support/register",
|
"source-map-support/register",
|
||||||
"test/report-why-tests-hang",
|
"test/report-why-tests-hang",
|
||||||
"test/init-mocha-webdriver",
|
"test/init-mocha-webdriver",
|
||||||
"test/split-tests",
|
"test/split-tests",
|
||||||
"test/chai-as-promised"]
|
"test/chai-as-promised"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { checkMinIOExternalStorage,
|
import { checkMinIOBucket, checkMinIOExternalStorage,
|
||||||
configureMinIOExternalStorage } from 'app/server/lib/configureMinIOExternalStorage';
|
configureMinIOExternalStorage } from 'app/server/lib/configureMinIOExternalStorage';
|
||||||
import { makeSimpleCreator } from 'app/server/lib/ICreate';
|
import { makeSimpleCreator } from 'app/server/lib/ICreate';
|
||||||
import { Telemetry } from 'app/server/lib/Telemetry';
|
import { Telemetry } from 'app/server/lib/Telemetry';
|
||||||
@ -12,6 +12,7 @@ export const create = makeSimpleCreator({
|
|||||||
{
|
{
|
||||||
name: 'minio',
|
name: 'minio',
|
||||||
check: () => checkMinIOExternalStorage() !== undefined,
|
check: () => checkMinIOExternalStorage() !== undefined,
|
||||||
|
checkBackend: () => checkMinIOBucket(),
|
||||||
create: configureMinIOExternalStorage,
|
create: configureMinIOExternalStorage,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -117,5 +117,7 @@ export async function main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (require.main === module) {
|
if (require.main === module) {
|
||||||
main().catch((err) => console.error(err));
|
main().catch((err) => {
|
||||||
|
console.error(err);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user