mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-24 17:28:31 +02:00
feat: proxmox idlewatcher (#88)
* feat: idle sleep for proxmox LXCs * refactor: replace deprecated docker api types * chore(api): remove debug task list endpoint * refactor: move servemux to gphttp/servemux; favicon.go to v1/favicon * refactor: introduce Pool interface, move agent_pool to agent module * refactor: simplify api code * feat: introduce debug api * refactor: remove net.URL and net.CIDR types, improved unmarshal handling * chore: update Makefile for debug build tag, update README * chore: add gperr.Unwrap method * feat: relative time and duration formatting * chore: add ROOT_DIR environment variable, refactor * migration: move homepage override and icon cache to $BASE_DIR/data, add migration code * fix: nil dereference on marshalling service health * fix: wait for route deletion * chore: enhance tasks debuggability * feat: stdout access logger and MultiWriter * fix(agent): remove agent properly on verify error * fix(metrics): disk exclusion logic and added corresponding tests * chore: update schema and prettify, fix package.json and Makefile * fix: I/O buffer not being shrunk before putting back to pool * feat: enhanced error handling module * chore: deps upgrade * feat: better value formatting and handling --------- Co-authored-by: yusing <yusing@6uo.me>
This commit is contained in:
52
schemas/providers/healthcheck.d.ts
vendored
52
schemas/providers/healthcheck.d.ts
vendored
@@ -3,30 +3,30 @@ import { Duration, URI } from "../types";
|
||||
* @additionalProperties false
|
||||
*/
|
||||
export type HealthcheckConfig = {
|
||||
/** Disable healthcheck
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
disable?: boolean;
|
||||
/** Healthcheck path
|
||||
*
|
||||
* @default /
|
||||
*/
|
||||
path?: URI;
|
||||
/**
|
||||
* Use GET instead of HEAD
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
use_get?: boolean;
|
||||
/** Healthcheck interval
|
||||
*
|
||||
* @default 5s
|
||||
*/
|
||||
interval?: Duration;
|
||||
/** Healthcheck timeout
|
||||
*
|
||||
* @default 5s
|
||||
*/
|
||||
timeout?: Duration;
|
||||
/** Disable healthcheck
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
disable?: boolean;
|
||||
/** Healthcheck path
|
||||
*
|
||||
* @default /
|
||||
*/
|
||||
path?: URI;
|
||||
/**
|
||||
* Use GET instead of HEAD
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
use_get?: boolean;
|
||||
/** Healthcheck interval
|
||||
*
|
||||
* @default 5s
|
||||
*/
|
||||
interval?: Duration;
|
||||
/** Healthcheck timeout
|
||||
*
|
||||
* @default 5s
|
||||
*/
|
||||
timeout?: Duration;
|
||||
};
|
||||
|
||||
26
schemas/providers/homepage.d.ts
vendored
26
schemas/providers/homepage.d.ts
vendored
@@ -3,19 +3,19 @@ import { URL } from "../types";
|
||||
* @additionalProperties false
|
||||
*/
|
||||
export type HomepageConfig = {
|
||||
/** Whether show in dashboard
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
show?: boolean;
|
||||
name?: string;
|
||||
icon?: URL | WalkxcodeIcon | ExternalIcon | TargetRelativeIconPath;
|
||||
description?: string;
|
||||
url?: URL;
|
||||
category?: string;
|
||||
widget_config?: {
|
||||
[key: string]: any;
|
||||
};
|
||||
/** Whether show in dashboard
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
show?: boolean;
|
||||
name?: string;
|
||||
icon?: URL | WalkxcodeIcon | ExternalIcon | TargetRelativeIconPath;
|
||||
description?: string;
|
||||
url?: URL;
|
||||
category?: string;
|
||||
widget_config?: {
|
||||
[key: string]: any;
|
||||
};
|
||||
};
|
||||
/** Walkxcode icon
|
||||
*
|
||||
|
||||
48
schemas/providers/idlewatcher.d.ts
vendored
48
schemas/providers/idlewatcher.d.ts
vendored
@@ -1,25 +1,35 @@
|
||||
import { Duration, URI } from "../types";
|
||||
export declare const STOP_METHODS: readonly ["pause", "stop", "kill"];
|
||||
export type StopMethod = (typeof STOP_METHODS)[number];
|
||||
export declare const STOP_SIGNALS: readonly ["", "SIGINT", "SIGTERM", "SIGHUP", "SIGQUIT", "INT", "TERM", "HUP", "QUIT"];
|
||||
export declare const STOP_SIGNALS: readonly [
|
||||
"",
|
||||
"SIGINT",
|
||||
"SIGTERM",
|
||||
"SIGHUP",
|
||||
"SIGQUIT",
|
||||
"INT",
|
||||
"TERM",
|
||||
"HUP",
|
||||
"QUIT",
|
||||
];
|
||||
export type Signal = (typeof STOP_SIGNALS)[number];
|
||||
export type IdleWatcherConfig = {
|
||||
idle_timeout?: Duration;
|
||||
/** Wake timeout
|
||||
*
|
||||
* @default 30s
|
||||
*/
|
||||
wake_timeout?: Duration;
|
||||
/** Stop timeout
|
||||
*
|
||||
* @default 30s
|
||||
*/
|
||||
stop_timeout?: Duration;
|
||||
/** Stop method
|
||||
*
|
||||
* @default stop
|
||||
*/
|
||||
stop_method?: StopMethod;
|
||||
stop_signal?: Signal;
|
||||
start_endpoint?: URI;
|
||||
idle_timeout?: Duration;
|
||||
/** Wake timeout
|
||||
*
|
||||
* @default 30s
|
||||
*/
|
||||
wake_timeout?: Duration;
|
||||
/** Stop timeout
|
||||
*
|
||||
* @default 30s
|
||||
*/
|
||||
stop_timeout?: Duration;
|
||||
/** Stop method
|
||||
*
|
||||
* @default stop
|
||||
*/
|
||||
stop_method?: StopMethod;
|
||||
stop_signal?: Signal;
|
||||
start_endpoint?: URI;
|
||||
};
|
||||
|
||||
46
schemas/providers/loadbalance.d.ts
vendored
46
schemas/providers/loadbalance.d.ts
vendored
@@ -1,28 +1,38 @@
|
||||
import { RealIP } from "../middlewares/middlewares";
|
||||
export declare const LOAD_BALANCE_MODES: readonly ["round_robin", "least_conn", "ip_hash"];
|
||||
export declare const LOAD_BALANCE_MODES: readonly [
|
||||
"round_robin",
|
||||
"least_conn",
|
||||
"ip_hash",
|
||||
];
|
||||
export type LoadBalanceMode = (typeof LOAD_BALANCE_MODES)[number];
|
||||
export type LoadBalanceConfigBase = {
|
||||
/** Alias (subdomain or FDN) of load-balancer
|
||||
*
|
||||
* @minLength 1
|
||||
*/
|
||||
link: string;
|
||||
/** Load-balance weight (reserved for future use)
|
||||
*
|
||||
* @minimum 0
|
||||
* @maximum 100
|
||||
*/
|
||||
weight?: number;
|
||||
/** Alias (subdomain or FDN) of load-balancer
|
||||
*
|
||||
* @minLength 1
|
||||
*/
|
||||
link: string;
|
||||
/** Load-balance weight (reserved for future use)
|
||||
*
|
||||
* @minimum 0
|
||||
* @maximum 100
|
||||
*/
|
||||
weight?: number;
|
||||
};
|
||||
export type LoadBalanceConfig = LoadBalanceConfigBase & ({} | RoundRobinLoadBalanceConfig | LeastConnLoadBalanceConfig | IPHashLoadBalanceConfig);
|
||||
export type LoadBalanceConfig = LoadBalanceConfigBase &
|
||||
(
|
||||
| {}
|
||||
| RoundRobinLoadBalanceConfig
|
||||
| LeastConnLoadBalanceConfig
|
||||
| IPHashLoadBalanceConfig
|
||||
);
|
||||
export type IPHashLoadBalanceConfig = {
|
||||
mode: "ip_hash";
|
||||
/** Real IP config, header to get client IP from */
|
||||
config: RealIP;
|
||||
mode: "ip_hash";
|
||||
/** Real IP config, header to get client IP from */
|
||||
config: RealIP;
|
||||
};
|
||||
export type LeastConnLoadBalanceConfig = {
|
||||
mode: "least_conn";
|
||||
mode: "least_conn";
|
||||
};
|
||||
export type RoundRobinLoadBalanceConfig = {
|
||||
mode: "round_robin";
|
||||
mode: "round_robin";
|
||||
};
|
||||
|
||||
238
schemas/providers/routes.d.ts
vendored
238
schemas/providers/routes.d.ts
vendored
@@ -1,7 +1,15 @@
|
||||
import { AccessLogConfig } from "../config/access_log";
|
||||
import { accessLogExamples } from "../config/entrypoint";
|
||||
import { MiddlewaresMap } from "../middlewares/middlewares";
|
||||
import { Duration, Hostname, IPv4, IPv6, PathPattern, Port, StreamPort } from "../types";
|
||||
import {
|
||||
Duration,
|
||||
Hostname,
|
||||
IPv4,
|
||||
IPv6,
|
||||
PathPattern,
|
||||
Port,
|
||||
StreamPort,
|
||||
} from "../types";
|
||||
import { HealthcheckConfig } from "./healthcheck";
|
||||
import { HomepageConfig } from "./homepage";
|
||||
import { LoadBalanceConfig } from "./loadbalance";
|
||||
@@ -11,122 +19,130 @@ export type ProxyScheme = (typeof PROXY_SCHEMES)[number];
|
||||
export type StreamScheme = (typeof STREAM_SCHEMES)[number];
|
||||
export type Route = ReverseProxyRoute | FileServerRoute | StreamRoute;
|
||||
export type Routes = {
|
||||
[key: string]: Route;
|
||||
[key: string]: Route;
|
||||
};
|
||||
export type ReverseProxyRoute = {
|
||||
/** Alias (subdomain or FDN)
|
||||
* @minLength 1
|
||||
*/
|
||||
alias?: string;
|
||||
/** Proxy scheme
|
||||
*
|
||||
* @default http
|
||||
*/
|
||||
scheme?: ProxyScheme;
|
||||
/** Proxy host
|
||||
*
|
||||
* @default localhost
|
||||
*/
|
||||
host?: Hostname | IPv4 | IPv6;
|
||||
/** Proxy port
|
||||
*
|
||||
* @default 80
|
||||
*/
|
||||
port?: Port;
|
||||
/** Skip TLS verification
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
no_tls_verify?: boolean;
|
||||
/** Response header timeout
|
||||
*
|
||||
* @default 60s
|
||||
*/
|
||||
response_header_timeout?: Duration;
|
||||
/** Path patterns (only patterns that match will be proxied).
|
||||
*
|
||||
* See https://pkg.go.dev/net/http#hdr-Patterns-ServeMux
|
||||
*/
|
||||
path_patterns?: PathPattern[];
|
||||
/** Healthcheck config */
|
||||
healthcheck?: HealthcheckConfig;
|
||||
/** Load balance config */
|
||||
load_balance?: LoadBalanceConfig;
|
||||
/** Middlewares */
|
||||
middlewares?: MiddlewaresMap;
|
||||
/** Homepage config
|
||||
*
|
||||
* @examples require(".").homepageExamples
|
||||
*/
|
||||
homepage?: HomepageConfig;
|
||||
/** Access log config
|
||||
*
|
||||
* @examples require(".").accessLogExamples
|
||||
*/
|
||||
access_log?: AccessLogConfig;
|
||||
/** Alias (subdomain or FDN)
|
||||
* @minLength 1
|
||||
*/
|
||||
alias?: string;
|
||||
/** Proxy scheme
|
||||
*
|
||||
* @default http
|
||||
*/
|
||||
scheme?: ProxyScheme;
|
||||
/** Proxy host
|
||||
*
|
||||
* @default localhost
|
||||
*/
|
||||
host?: Hostname | IPv4 | IPv6;
|
||||
/** Proxy port
|
||||
*
|
||||
* @default 80
|
||||
*/
|
||||
port?: Port;
|
||||
/** Skip TLS verification
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
no_tls_verify?: boolean;
|
||||
/** Response header timeout
|
||||
*
|
||||
* @default 60s
|
||||
*/
|
||||
response_header_timeout?: Duration;
|
||||
/** Path patterns (only patterns that match will be proxied).
|
||||
*
|
||||
* See https://pkg.go.dev/net/http#hdr-Patterns-ServeMux
|
||||
*/
|
||||
path_patterns?: PathPattern[];
|
||||
/** Healthcheck config */
|
||||
healthcheck?: HealthcheckConfig;
|
||||
/** Load balance config */
|
||||
load_balance?: LoadBalanceConfig;
|
||||
/** Middlewares */
|
||||
middlewares?: MiddlewaresMap;
|
||||
/** Homepage config
|
||||
*
|
||||
* @examples require(".").homepageExamples
|
||||
*/
|
||||
homepage?: HomepageConfig;
|
||||
/** Access log config
|
||||
*
|
||||
* @examples require(".").accessLogExamples
|
||||
*/
|
||||
access_log?: AccessLogConfig;
|
||||
};
|
||||
export type FileServerRoute = {
|
||||
/** Alias (subdomain or FDN)
|
||||
* @minLength 1
|
||||
*/
|
||||
alias?: string;
|
||||
scheme: "fileserver";
|
||||
root: string;
|
||||
/** Path patterns (only patterns that match will be proxied).
|
||||
*
|
||||
* See https://pkg.go.dev/net/http#hdr-Patterns-ServeMux
|
||||
*/
|
||||
path_patterns?: PathPattern[];
|
||||
/** Middlewares */
|
||||
middlewares?: MiddlewaresMap;
|
||||
/** Homepage config
|
||||
*
|
||||
* @examples require(".").homepageExamples
|
||||
*/
|
||||
homepage?: HomepageConfig;
|
||||
/** Access log config
|
||||
*
|
||||
* @examples require(".").accessLogExamples
|
||||
*/
|
||||
access_log?: AccessLogConfig;
|
||||
/** Alias (subdomain or FDN)
|
||||
* @minLength 1
|
||||
*/
|
||||
alias?: string;
|
||||
scheme: "fileserver";
|
||||
root: string;
|
||||
/** Path patterns (only patterns that match will be proxied).
|
||||
*
|
||||
* See https://pkg.go.dev/net/http#hdr-Patterns-ServeMux
|
||||
*/
|
||||
path_patterns?: PathPattern[];
|
||||
/** Middlewares */
|
||||
middlewares?: MiddlewaresMap;
|
||||
/** Homepage config
|
||||
*
|
||||
* @examples require(".").homepageExamples
|
||||
*/
|
||||
homepage?: HomepageConfig;
|
||||
/** Access log config
|
||||
*
|
||||
* @examples require(".").accessLogExamples
|
||||
*/
|
||||
access_log?: AccessLogConfig;
|
||||
/** Healthcheck config */
|
||||
healthcheck?: HealthcheckConfig;
|
||||
};
|
||||
export type StreamRoute = {
|
||||
/** Alias (subdomain or FDN)
|
||||
* @minLength 1
|
||||
*/
|
||||
alias?: string;
|
||||
/** Stream scheme
|
||||
*
|
||||
* @default tcp
|
||||
*/
|
||||
scheme?: StreamScheme;
|
||||
/** Stream host
|
||||
*
|
||||
* @default localhost
|
||||
*/
|
||||
host?: Hostname | IPv4 | IPv6;
|
||||
port: StreamPort;
|
||||
/** Healthcheck config */
|
||||
healthcheck?: HealthcheckConfig;
|
||||
/** Alias (subdomain or FDN)
|
||||
* @minLength 1
|
||||
*/
|
||||
alias?: string;
|
||||
/** Stream scheme
|
||||
*
|
||||
* @default tcp
|
||||
*/
|
||||
scheme?: StreamScheme;
|
||||
/** Stream host
|
||||
*
|
||||
* @default localhost
|
||||
*/
|
||||
host?: Hostname | IPv4 | IPv6;
|
||||
port: StreamPort;
|
||||
/** Healthcheck config */
|
||||
healthcheck?: HealthcheckConfig;
|
||||
};
|
||||
export declare const homepageExamples: ({
|
||||
name: string;
|
||||
icon: string;
|
||||
category: string;
|
||||
} | {
|
||||
name: string;
|
||||
icon: string;
|
||||
category?: undefined;
|
||||
})[];
|
||||
export declare const loadBalanceExamples: ({
|
||||
link: string;
|
||||
mode: string;
|
||||
config?: undefined;
|
||||
} | {
|
||||
link: string;
|
||||
mode: string;
|
||||
config: {
|
||||
export declare const homepageExamples: (
|
||||
| {
|
||||
name: string;
|
||||
icon: string;
|
||||
category: string;
|
||||
}
|
||||
| {
|
||||
name: string;
|
||||
icon: string;
|
||||
category?: undefined;
|
||||
}
|
||||
)[];
|
||||
export declare const loadBalanceExamples: (
|
||||
| {
|
||||
link: string;
|
||||
mode: string;
|
||||
config?: undefined;
|
||||
}
|
||||
| {
|
||||
link: string;
|
||||
mode: string;
|
||||
config: {
|
||||
header: string;
|
||||
};
|
||||
})[];
|
||||
};
|
||||
}
|
||||
)[];
|
||||
export { accessLogExamples };
|
||||
|
||||
@@ -1,7 +1,15 @@
|
||||
import { AccessLogConfig } from "../config/access_log";
|
||||
import { accessLogExamples } from "../config/entrypoint";
|
||||
import { MiddlewaresMap } from "../middlewares/middlewares";
|
||||
import { Duration, Hostname, IPv4, IPv6, PathPattern, Port, StreamPort } from "../types";
|
||||
import {
|
||||
Duration,
|
||||
Hostname,
|
||||
IPv4,
|
||||
IPv6,
|
||||
PathPattern,
|
||||
Port,
|
||||
StreamPort,
|
||||
} from "../types";
|
||||
import { HealthcheckConfig } from "./healthcheck";
|
||||
import { HomepageConfig } from "./homepage";
|
||||
import { LoadBalanceConfig } from "./loadbalance";
|
||||
@@ -94,7 +102,9 @@ export type FileServerRoute = {
|
||||
* @examples require(".").accessLogExamples
|
||||
*/
|
||||
access_log?: AccessLogConfig;
|
||||
}
|
||||
/** Healthcheck config */
|
||||
healthcheck?: HealthcheckConfig;
|
||||
};
|
||||
|
||||
export type StreamRoute = {
|
||||
/** Alias (subdomain or FDN)
|
||||
|
||||
Reference in New Issue
Block a user