mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-29 21:15:06 +02:00
UBERF-9224: Use context variables to hold context data (#7754)
Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
+4
-3
@@ -28,6 +28,7 @@ import {
|
||||
} from '@hcengineering/postgres'
|
||||
import { type DBDoc } from '@hcengineering/postgres/types/utils'
|
||||
import { getTransactorEndpoint } from '@hcengineering/server-client'
|
||||
import { sharedPipelineContextVars } from '@hcengineering/server-pipeline'
|
||||
import { generateToken } from '@hcengineering/server-token'
|
||||
import { connect } from '@hcengineering/server-tool'
|
||||
import { type MongoClient, UUID } from 'mongodb'
|
||||
@@ -45,7 +46,7 @@ export async function moveFromMongoToPG (
|
||||
}
|
||||
const client = getMongoClient(mongoUrl)
|
||||
const mongo = await client.getClient()
|
||||
const pg = getDBClient(dbUrl)
|
||||
const pg = getDBClient(sharedPipelineContextVars, dbUrl)
|
||||
const pgClient = await pg.getClient()
|
||||
|
||||
for (let index = 0; index < workspaces.length; index++) {
|
||||
@@ -168,7 +169,7 @@ export async function moveWorkspaceFromMongoToPG (
|
||||
}
|
||||
const client = getMongoClient(mongoUrl)
|
||||
const mongo = await client.getClient()
|
||||
const pg = getDBClient(dbUrl)
|
||||
const pg = getDBClient(sharedPipelineContextVars, dbUrl)
|
||||
const pgClient = await pg.getClient()
|
||||
|
||||
await moveWorkspace(accountDb, mongo, pgClient, ws, region, include, force)
|
||||
@@ -306,7 +307,7 @@ export async function updateDataWorkspaceIdToUuid (
|
||||
throw new Error('dbUrl is required')
|
||||
}
|
||||
|
||||
const pg = getDBClient(dbUrl)
|
||||
const pg = getDBClient(sharedPipelineContextVars, dbUrl)
|
||||
try {
|
||||
const pgClient = await pg.getClient()
|
||||
|
||||
|
||||
+29
-11
@@ -66,10 +66,11 @@ import {
|
||||
registerDestroyFactory,
|
||||
registerServerPlugins,
|
||||
registerStringLoaders,
|
||||
registerTxAdapterFactory
|
||||
registerTxAdapterFactory,
|
||||
sharedPipelineContextVars
|
||||
} from '@hcengineering/server-pipeline'
|
||||
import serverToken, { decodeToken, generateToken } from '@hcengineering/server-token'
|
||||
import { FileModelLogger, buildModel } from '@hcengineering/server-tool'
|
||||
import { buildModel, FileModelLogger } from '@hcengineering/server-tool'
|
||||
import { createWorkspace, upgradeWorkspace } from '@hcengineering/workspace-service'
|
||||
import path from 'path'
|
||||
|
||||
@@ -105,12 +106,18 @@ import {
|
||||
createMongoTxAdapter,
|
||||
getMongoClient,
|
||||
getWorkspaceMongoDB,
|
||||
shutdown
|
||||
shutdownMongo
|
||||
} from '@hcengineering/mongo'
|
||||
import { backupDownload } from '@hcengineering/server-backup/src/backup'
|
||||
|
||||
import { createDatalakeClient, CONFIG_KIND as DATALAKE_CONFIG_KIND, type DatalakeConfig } from '@hcengineering/datalake'
|
||||
import { getModelVersion } from '@hcengineering/model-all'
|
||||
import {
|
||||
createPostgreeDestroyAdapter,
|
||||
createPostgresAdapter,
|
||||
createPostgresTxAdapter,
|
||||
shutdownPostgres
|
||||
} from '@hcengineering/postgres'
|
||||
import { CONFIG_KIND as S3_CONFIG_KIND, S3Service, type S3Config } from '@hcengineering/s3'
|
||||
import type { PipelineFactory, StorageAdapter, StorageAdapterEx } from '@hcengineering/server-core'
|
||||
import { deepEqual } from 'fast-equals'
|
||||
@@ -139,17 +146,16 @@ import {
|
||||
import { changeConfiguration } from './configuration'
|
||||
import {
|
||||
generateUuidMissingWorkspaces,
|
||||
updateDataWorkspaceIdToUuid,
|
||||
moveAccountDbFromMongoToPG,
|
||||
moveFromMongoToPG,
|
||||
moveWorkspaceFromMongoToPG
|
||||
moveWorkspaceFromMongoToPG,
|
||||
updateDataWorkspaceIdToUuid
|
||||
} from './db'
|
||||
import { restoreControlledDocContentMongo, restoreWikiContentMongo, restoreMarkupRefsMongo } from './markup'
|
||||
import { reindexWorkspace } from './fulltext'
|
||||
import { restoreControlledDocContentMongo, restoreMarkupRefsMongo, restoreWikiContentMongo } from './markup'
|
||||
import { fixMixinForeignAttributes, showMixinForeignAttributes } from './mixin'
|
||||
import { fixAccountEmails, renameAccount, fillGithubUsers } from './account'
|
||||
import { copyToDatalake, moveFiles, showLostFiles } from './storage'
|
||||
import { createPostgresTxAdapter, createPostgresAdapter, createPostgreeDestroyAdapter } from '@hcengineering/postgres'
|
||||
import { reindexWorkspace } from './fulltext'
|
||||
|
||||
const colorConstants = {
|
||||
colorRed: '\u001b[31m',
|
||||
@@ -163,6 +169,16 @@ const colorConstants = {
|
||||
reset: '\u001b[0m'
|
||||
}
|
||||
|
||||
// Register close on process exit.
|
||||
process.on('exit', () => {
|
||||
shutdownPostgres(sharedPipelineContextVars).catch((err) => {
|
||||
console.error(err)
|
||||
})
|
||||
shutdownMongo(sharedPipelineContextVars).catch((err) => {
|
||||
console.error(err)
|
||||
})
|
||||
})
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
@@ -220,7 +236,7 @@ export function devTool (
|
||||
}
|
||||
closeAccountsDb()
|
||||
console.log(`closing database connection to '${uri}'...`)
|
||||
await shutdown()
|
||||
await shutdownMongo()
|
||||
}
|
||||
|
||||
async function withStorage (f: (storageAdapter: StorageAdapter) => Promise<any>): Promise<void> {
|
||||
@@ -648,6 +664,7 @@ export function devTool (
|
||||
true,
|
||||
true,
|
||||
5000, // 5 gigabytes per blob
|
||||
sharedPipelineContextVars,
|
||||
async (storage, workspaceStorage) => {
|
||||
if (cmd.remove) {
|
||||
await updateArchiveInfo(toolCtx, db, ws.workspace, true)
|
||||
@@ -667,7 +684,7 @@ export function devTool (
|
||||
|
||||
const destroyer = getWorkspaceDestroyAdapter(dbUrl)
|
||||
|
||||
await destroyer.deleteWorkspace(toolCtx, { name: ws.workspace })
|
||||
await destroyer.deleteWorkspace(toolCtx, sharedPipelineContextVars, { name: ws.workspace })
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -718,7 +735,8 @@ export function devTool (
|
||||
cmd.region,
|
||||
false,
|
||||
false,
|
||||
100
|
||||
100,
|
||||
sharedPipelineContextVars
|
||||
)
|
||||
) {
|
||||
processed++
|
||||
|
||||
Reference in New Issue
Block a user