feat: 增加环境变量用于禁用日志选项

pull/70/head
moonrailgun 2 years ago
parent 4088de907f
commit de37f647a0

@ -1,5 +1,15 @@
import brokerConfig from 'tailchat-server-sdk/dist/runner/moleculer.config';
import {
defaultBrokerConfig,
config,
BrokerOptions,
} from 'tailchat-server-sdk';
export default {
...brokerConfig,
const brokerConfig: BrokerOptions = {
...defaultBrokerConfig,
};
if (config.feature.disableLogger === true) {
brokerConfig.logger = false;
}
export default brokerConfig;

@ -1,3 +1,4 @@
export { defaultBrokerConfig } from './runner/moleculer.config';
export { TcService } from './services/base';
export { TcBroker } from './services/broker';
export type { TcDbService } from './services/mixins/db.mixin';
@ -49,6 +50,7 @@ export * from './const';
// other
export { Utils, Errors } from 'moleculer';
export type { BrokerOptions } from 'moleculer';
/**
* ,

@ -36,7 +36,7 @@ import 'moleculer-repl';
* }
* }
*/
const brokerConfig: BrokerOptions = {
export const defaultBrokerConfig: BrokerOptions = {
// Namespace of nodes to segment your nodes on the same network.
namespace: 'tailchat',
// Unique node identifier. Must be unique in a namespace.
@ -310,5 +310,3 @@ const brokerConfig: BrokerOptions = {
stopped: async (broker: ServiceBroker): Promise<void> => {},
*/
};
export default brokerConfig;

@ -37,6 +37,7 @@ export const config = {
apiUrl,
staticUrl: `${apiUrl}/static/`,
enableOpenapi: true, // 是否开始openapi
emailVerification: checkEnvTrusty(process.env.EMAIL_VERIFY) || false, // 是否在注册后验证邮箱可用性
smtp: {
senderName: process.env.SMTP_SENDER, // 发邮件者显示名称
@ -45,6 +46,7 @@ export const config = {
enablePrometheus: checkEnvTrusty(process.env.PROMETHEUS),
feature: {
disableFileCheck: checkEnvTrusty(process.env.DISABLE_FILE_CHECK),
disableLogger: checkEnvTrusty(process.env.DISABLE_LOGGER), // 是否关闭日志
},
};

@ -20,6 +20,7 @@ title: 环境变量
| SMTP_URI | - | 邮件服务连接地址(示例: `smtp://username:password@smtp.example.com/?pool=true`) |
| FILE_LIMIT | 1048576 | 文件/图片上传的大小限制默认为1m请输入数字 |
| EMAIL_VERIFY | - | 是否开启邮箱校验, 如果为 "1" 或者 "true" 则在注册时增加邮箱校验控制 |
| DISABLE_LOGGER | - | 是否禁用日志输出, 如果为 "1" 或者 "true" 则在运行中关闭日志 |
> 部分环境变量示例可见: https://github.com/msgbyte/tailchat/blob/master/server/.env.example

Loading…
Cancel
Save