feat(runtime): override deploy settings from the environment
SNOWLUMA_ variables can set the factory OneBot listen ports, WebUI TLS, packet and hook timeouts, the stream directory, file download timeout, and notification HTTP timeout. The values apply in memory and are not written back to saved config.
This commit is contained in:
19 files changed
+342
-14
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import type { PacketSender, SendPacketResult } from '@snowluma/common/packet-sender';
|
||||
import { packetTimeoutMs } from './packet-timeout';
|
||||
import {
|
||||
HookPipeRequestError,
|
||||
PIPE_STATUS_CONNECTION_UNAVAILABLE,
|
||||
@@ -16,7 +17,7 @@ export class HookPacketClient implements PacketSender {
|
||||
private readonly onOutboundHealthChanged?: OutboundHealthListener,
|
||||
) { }
|
||||
|
||||
async sendPacket(serviceCmd: string, body: Buffer, timeoutMs = 15000): Promise<SendPacketResult> {
|
||||
async sendPacket(serviceCmd: string, body: Buffer, timeoutMs = packetTimeoutMs()): Promise<SendPacketResult> {
|
||||
if (!this.client.isLoggedIn) {
|
||||
return { success: false, gotResponse: false, errorCode: -1, errorMessage: 'qq_hook client is not logged in', responseData: null };
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import { positiveIntEnv } from '@snowluma/common/env';
|
||||
|
||||
/** Default wait for a QQ reply when the caller does not pass one. */
|
||||
export const DEFAULT_PACKET_TIMEOUT_MS = 15_000;
|
||||
|
||||
export function packetTimeoutMs(env?: NodeJS.ProcessEnv): number {
|
||||
return positiveIntEnv('SNOWLUMA_PACKET_TIMEOUT_MS', DEFAULT_PACKET_TIMEOUT_MS, { env });
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import { isRealUin } from '@snowluma/common/uin';
|
||||
import { readdirSync, promises as fs } from 'fs';
|
||||
import net from 'net';
|
||||
import path from 'path';
|
||||
import { positiveIntEnv } from '@snowluma/common/env';
|
||||
import { resolveHookRuntimeDir } from './hook-runtime-dir';
|
||||
|
||||
export const PIPE_MAGIC = 0x31504851;
|
||||
@@ -471,7 +472,7 @@ export class QqHookClient extends EventEmitter {
|
||||
private loginWaiters: Deferred<QqHookLoginState>[] = [];
|
||||
|
||||
constructor(pid: number, {
|
||||
ackTimeoutMs = DEFAULT_ACK_TIMEOUT_MS,
|
||||
ackTimeoutMs = positiveIntEnv('SNOWLUMA_HOOK_ACK_TIMEOUT_MS', DEFAULT_ACK_TIMEOUT_MS),
|
||||
replyTimeoutMs = DEFAULT_REPLY_TIMEOUT_MS,
|
||||
runtimeDir = resolveHookRuntimeDir(pid),
|
||||
}: QqHookClientOptions = {}) {
|
||||
|
||||
Reference in new issue
Block a user