Skip to content

Commit

Permalink
feat: add env REQUEST_TIMEOUT to custom requestTimeout of actions
Browse files Browse the repository at this point in the history
  • Loading branch information
moonrailgun committed Nov 3, 2023
1 parent 424f861 commit d678d0a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion server/packages/sdk/src/runner/moleculer.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export const defaultBrokerConfig: BrokerOptions = {
serializer: 'JSON',

// Number of milliseconds to wait before reject a request with a RequestTimeout error. Disabled: 0
requestTimeout: 10 * 1000,
requestTimeout: config.runner.requestTimeout,

// Retry policy settings. More info: https://moleculer.services/docs/0.14/fault-tolerance.html#Retry
retryPolicy: {
Expand Down
7 changes: 7 additions & 0 deletions server/packages/sdk/src/services/lib/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ const port = process.env.PORT ? Number(process.env.PORT) : 11000;
const apiUrl = process.env.API_URL || `http://127.0.0.1:${port}`;
const staticHost = process.env.STATIC_HOST || '{BACKEND}';
const staticUrl = process.env.STATIC_URL || `${staticHost}/static/`;
const requestTimeout = process.env.REQUEST_TIMEOUT
? Number(process.env.REQUEST_TIMEOUT)
: 10 * 1000; // default 0 (unit: milliseconds)

export const config = {
port,
secret: process.env.SECRET || 'tailchat',
Expand Down Expand Up @@ -47,6 +51,9 @@ export const config = {
connectionUrl: process.env.SMTP_URI || '',
},
enablePrometheus: checkEnvTrusty(process.env.PROMETHEUS),
runner: {
requestTimeout,
},
feature: {
disableFileCheck: checkEnvTrusty(process.env.DISABLE_FILE_CHECK),
disableLogger: checkEnvTrusty(process.env.DISABLE_LOGGER), // 是否关闭日志
Expand Down
1 change: 1 addition & 0 deletions website/docs/deployment/environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ title: Environment Variable
| SMTP_URI | - | mail service connection address (example: `smtp://username:[email protected]/?pool=true`) |
| FILE_LIMIT | 1048576 | File/image upload size limit, the default is 1m, please enter a number(unit: byte) |
| EMAIL_VERIFY | - | Whether to enable email verification, if it is "1" or "true", add email verification control when registering |
| REQUEST_TIMEOUT | 10 * 1000 | Number of milliseconds to wait before reject a request with a RequestTimeout error. Disabled: 0 |
| DISABLE_LOGGER | - | Whether to disable the log output, if "1" or "true" turn off the log on the fly |
| DISABLE_USER_REGISTER | - | Whether to disable the user register, if "1" or "true" turn off this method |
| DISABLE_GUEST_LOGIN | - | Whether to disable the guest login, if "1" or "true" turn off this method |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ title: 环境变量
| SMTP_URI | - | 邮件服务连接地址(示例: `smtp://username:[email protected]/?pool=true`) |
| FILE_LIMIT | 1048576 | 文件/图片上传的大小限制,默认为1m,请输入数字,(单位: 字节) |
| EMAIL_VERIFY | - | 是否开启邮箱校验, 如果为 "1" 或者 "true" 则在注册时增加邮箱校验控制 |
| REQUEST_TIMEOUT | 10 * 1000 | 请求超时毫秒数,请求超过该时间没有完成会抛出 `RequestTimeout` 错误。 如果需要禁用请求超时限制传:0 |
| DISABLE_LOGGER | - | 是否禁用日志输出, 如果为 "1" 或者 "true" 则在运行中关闭日志 |
| DISABLE_USER_REGISTER | - | 是否关闭用户注册功能, 如果为 "1" 或者 "true" 则关闭该功能 |
| DISABLE_GUEST_LOGIN | - | 是否关闭用户游客登录功能, 如果为 "1" 或者 "true" 则关闭该功能 |
Expand Down

0 comments on commit d678d0a

Please sign in to comment.