diff options
| author | Marie <github@yuugi.dev> | 2025-05-30 16:25:28 +0000 |
|---|---|---|
| committer | Marie <github@yuugi.dev> | 2025-05-30 16:25:28 +0000 |
| commit | 5d8a8bba2a0fa7af0171658e7a6959c131dbf108 (patch) | |
| tree | 500a6801e15f1d33c648ff9e91f8e0bd1d3c3540 /packages/backend | |
| parent | merge: Increase chart rate limits (!1065) (diff) | |
| parent | use standard logger class in config.ts (diff) | |
| download | sharkey-5d8a8bba2a0fa7af0171658e7a6959c131dbf108.tar.gz sharkey-5d8a8bba2a0fa7af0171658e7a6959c131dbf108.tar.bz2 sharkey-5d8a8bba2a0fa7af0171658e7a6959c131dbf108.zip | |
merge: Log config file paths at startup (!1066)
View MR for information: https://activitypub.software/TransFem-org/Sharkey/-/merge_requests/1066
Approved-by: dakkar <dakkar@thenautilus.net>
Approved-by: Marie <github@yuugi.dev>
Diffstat (limited to 'packages/backend')
| -rw-r--r-- | packages/backend/src/config.ts | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/packages/backend/src/config.ts b/packages/backend/src/config.ts index 8507420839..d61112ae40 100644 --- a/packages/backend/src/config.ts +++ b/packages/backend/src/config.ts @@ -9,6 +9,7 @@ import { dirname, resolve } from 'node:path'; import * as yaml from 'js-yaml'; import { globSync } from 'glob'; import ipaddr from 'ipaddr.js'; +import Logger from './logger.js'; import type * as Sentry from '@sentry/node'; import type * as SentryVue from '@sentry/vue'; import type { RedisOptions } from 'ioredis'; @@ -155,6 +156,8 @@ type Source = { } }; +const configLogger = new Logger('config'); + export type PrivateNetworkSource = string | { network?: string, ports?: number[] }; export type PrivateNetwork = { @@ -192,7 +195,7 @@ export function parsePrivateNetworks(patterns: PrivateNetworkSource[] | undefine } } - console.warn('[config] Skipping invalid entry in allowedPrivateNetworks: ', e); + configLogger.warn('Skipping invalid entry in allowedPrivateNetworks: ', e); return null; }) .filter(p => p != null); @@ -375,11 +378,14 @@ export function loadConfig(): Config { if (configFiles.length === 0 && !process.env['MK_WARNED_ABOUT_CONFIG']) { - console.log('No config files loaded, check if this is intentional'); + configLogger.warn('No config files loaded, check if this is intentional'); process.env['MK_WARNED_ABOUT_CONFIG'] = '1'; } - const config = configFiles.map(path => fs.readFileSync(path, 'utf-8')) + const config = configFiles.map(path => { + configLogger.info(`Reading configuration from ${path}`); + return fs.readFileSync(path, 'utf-8'); + }) .map(contents => yaml.load(contents) as Source) .reduce( (acc: Source, cur: Source) => Object.assign(acc, cur), @@ -496,6 +502,10 @@ export function loadConfig(): Config { } function tryCreateUrl(url: string) { + if (!url) { + throw new Error('Failed to load: no "url" property found in config. Please check the value of "MISSKEY_CONFIG_DIR" and "MISSKEY_CONFIG_YML", and verify that all configuration files are correct.'); + } + try { return new URL(url); } catch (e) { |