diff --git a/server/storage/database.ts b/server/storage/database.ts index e683cf91b9..fd2fde89fb 100644 --- a/server/storage/database.ts +++ b/server/storage/database.ts @@ -9,6 +9,7 @@ import env from "@server/env"; import type Model from "@server/models/base/Model"; import Logger from "../logging/Logger"; import * as models from "../models"; +import { getConnectionName } from "./utils"; /** * Returns database configuration for Sequelize constructor. @@ -64,6 +65,7 @@ export function createDatabaseInstance( typeValidation: true, logQueryParameters: env.isDevelopment, dialectOptions: { + application_name: getConnectionName(), ssl: env.isProduction && !isSSLDisabled ? { diff --git a/server/storage/redis.ts b/server/storage/redis.ts index 37e95ab3a8..90ea9f959a 100644 --- a/server/storage/redis.ts +++ b/server/storage/redis.ts @@ -3,6 +3,7 @@ import Redis from "ioredis"; import defaults from "lodash/defaults"; import env from "@server/env"; import Logger from "@server/logging/Logger"; +import { getConnectionName } from "./utils"; type RedisAdapterOptions = RedisOptions & { /** Suffix to append to the connection name that will be displayed in Redis */ @@ -42,14 +43,7 @@ export default class RedisAdapter extends Redis { url: string | undefined, { connectionNameSuffix, ...options }: RedisAdapterOptions = {} ) { - /** - * For debugging. The connection name is based on the services running in - * this process. Note that this does not need to be unique. - */ - const connectionNamePrefix = env.isDevelopment ? process.pid : "outline"; - const connectionName = - `${connectionNamePrefix}:${env.SERVICES.join("-")}` + - (connectionNameSuffix ? `:${connectionNameSuffix}` : ""); + const connectionName = getConnectionName(connectionNameSuffix); if (!url || !url.startsWith("ioredis://")) { super( diff --git a/server/storage/utils.ts b/server/storage/utils.ts new file mode 100644 index 0000000000..1e17d76ca4 --- /dev/null +++ b/server/storage/utils.ts @@ -0,0 +1,13 @@ +import env from "@server/env"; + +/** + * For debugging. The connection name is based on the services running in + * this process. Note that this does not need to be unique. + */ +export const getConnectionName = (connectionNameSuffix?: string) => { + const connectionNamePrefix = env.isDevelopment ? process.pid : "outline"; + return ( + `${connectionNamePrefix}:${env.SERVICES.join("-")}` + + (connectionNameSuffix ? `:${connectionNameSuffix}` : "") + ); +};