mirror of
https://github.com/hcengineering/platform.git
synced 2025-01-03 00:43:59 +03:00
UBERF-9025: Fix backup service (#7557)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
parent
d0af7a37cc
commit
fb5df1681d
@ -62,9 +62,9 @@ import {
|
||||
createBackupPipeline,
|
||||
getConfig,
|
||||
getWorkspaceDestroyAdapter,
|
||||
registerAdapterFactry,
|
||||
registerDestroyFactry,
|
||||
registerTxAdapterFactry
|
||||
registerAdapterFactory,
|
||||
registerDestroyFactory,
|
||||
registerTxAdapterFactory
|
||||
} from '@hcengineering/server-pipeline'
|
||||
import serverToken, { decodeToken, generateToken } from '@hcengineering/server-token'
|
||||
import { FileModelLogger } from '@hcengineering/server-tool'
|
||||
@ -173,13 +173,13 @@ export function devTool (
|
||||
): void {
|
||||
const toolCtx = new MeasureMetricsContext('tool', {})
|
||||
|
||||
registerTxAdapterFactry('mongodb', createMongoTxAdapter)
|
||||
registerAdapterFactry('mongodb', createMongoAdapter)
|
||||
registerDestroyFactry('mongodb', createMongoDestroyAdapter)
|
||||
registerTxAdapterFactory('mongodb', createMongoTxAdapter)
|
||||
registerAdapterFactory('mongodb', createMongoAdapter)
|
||||
registerDestroyFactory('mongodb', createMongoDestroyAdapter)
|
||||
|
||||
registerTxAdapterFactry('postgresql', createPostgresTxAdapter, true)
|
||||
registerAdapterFactry('postgresql', createPostgresAdapter, true)
|
||||
registerDestroyFactry('postgresql', createPostgreeDestroyAdapter, true)
|
||||
registerTxAdapterFactory('postgresql', createPostgresTxAdapter, true)
|
||||
registerAdapterFactory('postgresql', createPostgresAdapter, true)
|
||||
registerDestroyFactory('postgresql', createPostgreeDestroyAdapter, true)
|
||||
|
||||
const serverSecret = process.env.SERVER_SECRET
|
||||
if (serverSecret === undefined) {
|
||||
|
@ -81,7 +81,7 @@ export const storePromise = writable<Promise<void>>(new Promise((resolve) => {})
|
||||
|
||||
function fillStores (): void {
|
||||
const client = getClient()
|
||||
if (client !== undefined) {
|
||||
if (client !== undefined || getCurrentAccount() != null) {
|
||||
const query = createQuery(true)
|
||||
const roomPromise = new Promise<void>((resolve) =>
|
||||
query.query(love.class.Room, {}, (res) => {
|
||||
|
@ -60,6 +60,8 @@
|
||||
"dotenv": "~16.0.0",
|
||||
"@hcengineering/backup-service": "^0.6.0",
|
||||
"@hcengineering/analytics": "^0.6.0",
|
||||
"@hcengineering/analytics-service": "^0.6.0"
|
||||
"@hcengineering/analytics-service": "^0.6.0",
|
||||
"@hcengineering/mongo": "^0.6.1",
|
||||
"@hcengineering/postgres": "^0.6.0"
|
||||
}
|
||||
}
|
||||
|
@ -18,10 +18,18 @@ import { configureAnalytics, SplitLogger } from '@hcengineering/analytics-servic
|
||||
import { startBackup } from '@hcengineering/backup-service'
|
||||
import { MeasureMetricsContext, newMetrics, type Tx } from '@hcengineering/core'
|
||||
import { initStatisticsContext, type PipelineFactory } from '@hcengineering/server-core'
|
||||
import { createBackupPipeline, getConfig } from '@hcengineering/server-pipeline'
|
||||
import {
|
||||
createBackupPipeline,
|
||||
getConfig,
|
||||
registerAdapterFactory,
|
||||
registerDestroyFactory,
|
||||
registerTxAdapterFactory
|
||||
} from '@hcengineering/server-pipeline'
|
||||
import { join } from 'path'
|
||||
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { createMongoTxAdapter, createMongoAdapter, createMongoDestroyAdapter } from '@hcengineering/mongo'
|
||||
import { createPostgresTxAdapter, createPostgresAdapter, createPostgreeDestroyAdapter } from '@hcengineering/postgres'
|
||||
const model = JSON.parse(readFileSync(process.env.MODEL_JSON ?? 'model.json').toString()) as Tx[]
|
||||
|
||||
const metricsContext = initStatisticsContext('backup', {
|
||||
@ -43,6 +51,14 @@ const sentryDSN = process.env.SENTRY_DSN
|
||||
configureAnalytics(sentryDSN, {})
|
||||
Analytics.setTag('application', 'backup-service')
|
||||
|
||||
registerTxAdapterFactory('mongodb', createMongoTxAdapter)
|
||||
registerAdapterFactory('mongodb', createMongoAdapter)
|
||||
registerDestroyFactory('mongodb', createMongoDestroyAdapter)
|
||||
|
||||
registerTxAdapterFactory('postgresql', createPostgresTxAdapter, true)
|
||||
registerAdapterFactory('postgresql', createPostgresAdapter, true)
|
||||
registerDestroyFactory('postgresql', createPostgreeDestroyAdapter, true)
|
||||
|
||||
startBackup(
|
||||
metricsContext,
|
||||
(mongoUrl, storageAdapter) => {
|
||||
|
@ -47,11 +47,11 @@ import serverCore, {
|
||||
import { FullTextIndexPipeline, searchFulltext, type FulltextDBConfiguration } from '@hcengineering/server-indexer'
|
||||
import {
|
||||
getConfig,
|
||||
registerAdapterFactry,
|
||||
registerDestroyFactry,
|
||||
registerAdapterFactory,
|
||||
registerDestroyFactory,
|
||||
registerServerPlugins,
|
||||
registerStringLoaders,
|
||||
registerTxAdapterFactry
|
||||
registerTxAdapterFactory
|
||||
} from '@hcengineering/server-pipeline'
|
||||
import serverToken, { decodeToken, generateToken, type Token } from '@hcengineering/server-token'
|
||||
import cors from '@koa/cors'
|
||||
@ -207,13 +207,13 @@ export async function startIndexer (
|
||||
setMetadata(serverCore.metadata.ElasticIndexName, opt.elasticIndexName)
|
||||
setMetadata(serverClientPlugin.metadata.Endpoint, opt.accountsUrl)
|
||||
|
||||
registerTxAdapterFactry('mongodb', createMongoTxAdapter)
|
||||
registerAdapterFactry('mongodb', createMongoAdapter)
|
||||
registerDestroyFactry('mongodb', createMongoDestroyAdapter)
|
||||
registerTxAdapterFactory('mongodb', createMongoTxAdapter)
|
||||
registerAdapterFactory('mongodb', createMongoAdapter)
|
||||
registerDestroyFactory('mongodb', createMongoDestroyAdapter)
|
||||
|
||||
registerTxAdapterFactry('postgresql', createPostgresTxAdapter, true)
|
||||
registerAdapterFactry('postgresql', createPostgresAdapter, true)
|
||||
registerDestroyFactry('postgresql', createPostgreeDestroyAdapter, true)
|
||||
registerTxAdapterFactory('postgresql', createPostgresTxAdapter, true)
|
||||
registerAdapterFactory('postgresql', createPostgresAdapter, true)
|
||||
registerDestroyFactory('postgresql', createPostgreeDestroyAdapter, true)
|
||||
|
||||
registerServerPlugins()
|
||||
registerStringLoaders()
|
||||
|
@ -35,11 +35,11 @@ import { type Token } from '@hcengineering/server-token'
|
||||
|
||||
import {
|
||||
createServerPipeline,
|
||||
registerAdapterFactry,
|
||||
registerDestroyFactry,
|
||||
registerAdapterFactory,
|
||||
registerDestroyFactory,
|
||||
registerServerPlugins,
|
||||
registerStringLoaders,
|
||||
registerTxAdapterFactry
|
||||
registerTxAdapterFactory
|
||||
} from '@hcengineering/server-pipeline'
|
||||
|
||||
import { readFileSync } from 'node:fs'
|
||||
@ -74,13 +74,13 @@ export function start (
|
||||
mongoUrl?: string
|
||||
}
|
||||
): { shutdown: () => Promise<void>, sessionManager: SessionManager } {
|
||||
registerTxAdapterFactry('mongodb', createMongoTxAdapter)
|
||||
registerAdapterFactry('mongodb', createMongoAdapter)
|
||||
registerDestroyFactry('mongodb', createMongoDestroyAdapter)
|
||||
registerTxAdapterFactory('mongodb', createMongoTxAdapter)
|
||||
registerAdapterFactory('mongodb', createMongoAdapter)
|
||||
registerDestroyFactory('mongodb', createMongoDestroyAdapter)
|
||||
|
||||
registerTxAdapterFactry('postgresql', createPostgresTxAdapter, true)
|
||||
registerAdapterFactry('postgresql', createPostgresAdapter, true)
|
||||
registerDestroyFactry('postgresql', createPostgreeDestroyAdapter, true)
|
||||
registerTxAdapterFactory('postgresql', createPostgresTxAdapter, true)
|
||||
registerAdapterFactory('postgresql', createPostgresAdapter, true)
|
||||
registerDestroyFactory('postgresql', createPostgreeDestroyAdapter, true)
|
||||
|
||||
registerServerPlugins()
|
||||
|
||||
|
@ -210,21 +210,21 @@ const txAdapterFactories: Record<string, DbAdapterFactory> = {}
|
||||
const adapterFactories: Record<string, DbAdapterFactory> = {}
|
||||
const destroyFactories: Record<string, (url: string) => WorkspaceDestroyAdapter> = {}
|
||||
|
||||
export function registerTxAdapterFactry (name: string, factory: DbAdapterFactory, useAsDefault: boolean = true): void {
|
||||
export function registerTxAdapterFactory (name: string, factory: DbAdapterFactory, useAsDefault: boolean = true): void {
|
||||
txAdapterFactories[name] = factory
|
||||
if (useAsDefault) {
|
||||
txAdapterFactories[''] = factory
|
||||
}
|
||||
}
|
||||
|
||||
export function registerAdapterFactry (name: string, factory: DbAdapterFactory, useAsDefault: boolean = true): void {
|
||||
export function registerAdapterFactory (name: string, factory: DbAdapterFactory, useAsDefault: boolean = true): void {
|
||||
adapterFactories[name] = factory
|
||||
if (useAsDefault) {
|
||||
adapterFactories[''] = factory
|
||||
}
|
||||
}
|
||||
|
||||
export function registerDestroyFactry (
|
||||
export function registerDestroyFactory (
|
||||
name: string,
|
||||
factory: (url: string) => WorkspaceDestroyAdapter,
|
||||
useAsDefault: boolean = true
|
||||
|
@ -21,11 +21,11 @@ import { SessionDataImpl, wrapPipeline, type Pipeline, type StorageAdapter } fro
|
||||
import {
|
||||
getServerPipeline,
|
||||
getTxAdapterFactory,
|
||||
registerAdapterFactry,
|
||||
registerDestroyFactry,
|
||||
registerAdapterFactory,
|
||||
registerDestroyFactory,
|
||||
registerServerPlugins,
|
||||
registerStringLoaders,
|
||||
registerTxAdapterFactry
|
||||
registerTxAdapterFactory
|
||||
} from '@hcengineering/server-pipeline'
|
||||
import { buildStorageFromConfig, storageConfigFromEnv } from '@hcengineering/server-storage'
|
||||
import { generateToken } from '@hcengineering/server-token'
|
||||
@ -82,13 +82,13 @@ export async function createWorkspace (
|
||||
const hierarchy = new Hierarchy()
|
||||
const modelDb = new ModelDb(hierarchy)
|
||||
|
||||
registerTxAdapterFactry('mongodb', createMongoTxAdapter)
|
||||
registerAdapterFactry('mongodb', createMongoAdapter)
|
||||
registerDestroyFactry('mongodb', createMongoDestroyAdapter)
|
||||
registerTxAdapterFactory('mongodb', createMongoTxAdapter)
|
||||
registerAdapterFactory('mongodb', createMongoAdapter)
|
||||
registerDestroyFactory('mongodb', createMongoDestroyAdapter)
|
||||
|
||||
registerTxAdapterFactry('postgresql', createPostgresTxAdapter, true)
|
||||
registerAdapterFactry('postgresql', createPostgresAdapter, true)
|
||||
registerDestroyFactry('postgresql', createPostgreeDestroyAdapter, true)
|
||||
registerTxAdapterFactory('postgresql', createPostgresTxAdapter, true)
|
||||
registerAdapterFactory('postgresql', createPostgresAdapter, true)
|
||||
registerDestroyFactory('postgresql', createPostgreeDestroyAdapter, true)
|
||||
registerServerPlugins()
|
||||
registerStringLoaders()
|
||||
|
||||
@ -173,13 +173,13 @@ export async function upgradeWorkspace (
|
||||
): Promise<void> {
|
||||
const { dbUrl } = prepareTools([])
|
||||
let pipeline: Pipeline | undefined
|
||||
registerTxAdapterFactry('mongodb', createMongoTxAdapter)
|
||||
registerAdapterFactry('mongodb', createMongoAdapter)
|
||||
registerDestroyFactry('mongodb', createMongoDestroyAdapter)
|
||||
registerTxAdapterFactory('mongodb', createMongoTxAdapter)
|
||||
registerAdapterFactory('mongodb', createMongoAdapter)
|
||||
registerDestroyFactory('mongodb', createMongoDestroyAdapter)
|
||||
|
||||
registerTxAdapterFactry('postgresql', createPostgresTxAdapter, true)
|
||||
registerAdapterFactry('postgresql', createPostgresAdapter, true)
|
||||
registerDestroyFactry('postgresql', createPostgreeDestroyAdapter, true)
|
||||
registerTxAdapterFactory('postgresql', createPostgresTxAdapter, true)
|
||||
registerAdapterFactory('postgresql', createPostgresAdapter, true)
|
||||
registerDestroyFactory('postgresql', createPostgreeDestroyAdapter, true)
|
||||
|
||||
registerServerPlugins()
|
||||
registerStringLoaders()
|
||||
|
@ -38,11 +38,11 @@ import { gzip } from 'zlib'
|
||||
import { createPostgreeDestroyAdapter, createPostgresAdapter, createPostgresTxAdapter } from '@hcengineering/postgres'
|
||||
import {
|
||||
createServerPipeline,
|
||||
registerAdapterFactry,
|
||||
registerDestroyFactry,
|
||||
registerAdapterFactory,
|
||||
registerDestroyFactory,
|
||||
registerServerPlugins,
|
||||
registerStringLoaders,
|
||||
registerTxAdapterFactry
|
||||
registerTxAdapterFactory
|
||||
} from '@hcengineering/server-pipeline'
|
||||
import model from './model.json'
|
||||
|
||||
@ -65,9 +65,9 @@ export class Transactor extends DurableObject<Env> {
|
||||
constructor (ctx: DurableObjectState, env: Env) {
|
||||
super(ctx, env)
|
||||
|
||||
registerTxAdapterFactry('postgresql', createPostgresTxAdapter, true)
|
||||
registerAdapterFactry('postgresql', createPostgresAdapter, true)
|
||||
registerDestroyFactry('postgresql', createPostgreeDestroyAdapter, true)
|
||||
registerTxAdapterFactory('postgresql', createPostgresTxAdapter, true)
|
||||
registerAdapterFactory('postgresql', createPostgresAdapter, true)
|
||||
registerDestroyFactory('postgresql', createPostgreeDestroyAdapter, true)
|
||||
|
||||
registerStringLoaders()
|
||||
registerServerPlugins()
|
||||
|
Loading…
Reference in New Issue
Block a user