refactor: manage monitor via gateway hooks
This commit is contained in:
35
plugin/core/config.ts
Normal file
35
plugin/core/config.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { hostname } from 'os';
|
||||
|
||||
export interface HarborForgePluginConfig {
|
||||
enabled?: boolean;
|
||||
backendUrl?: string;
|
||||
identifier?: string;
|
||||
apiKey?: string;
|
||||
monitor_port?: number;
|
||||
reportIntervalSec?: number;
|
||||
httpFallbackIntervalSec?: number;
|
||||
logLevel?: 'debug' | 'info' | 'warn' | 'error';
|
||||
calendarEnabled?: boolean;
|
||||
calendarHeartbeatIntervalSec?: number;
|
||||
calendarApiKey?: string;
|
||||
managedMonitor?: string;
|
||||
}
|
||||
|
||||
interface PluginApiLike {
|
||||
pluginConfig?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
export function getPluginConfig(api: PluginApiLike): HarborForgePluginConfig {
|
||||
const cfg = (api.pluginConfig || {}) as HarborForgePluginConfig;
|
||||
return {
|
||||
enabled: true,
|
||||
backendUrl: 'https://monitor.hangman-lab.top',
|
||||
identifier: hostname(),
|
||||
reportIntervalSec: 30,
|
||||
httpFallbackIntervalSec: 60,
|
||||
logLevel: 'info',
|
||||
calendarEnabled: true,
|
||||
calendarHeartbeatIntervalSec: 60,
|
||||
...cfg,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user