mirror of
https://github.com/whyour/qinglong.git
synced 2026-12-01 01:39:52 +08:00
feat: harden cron execution recovery and expose scheduling diagnostics
Reconcile scheduled and system cron triggers, isolate concurrent executions and retain verifiable exit statistics across restarts. Add paged task history, log and script browsing, dashboard timing details and regression coverage.
This commit is contained in:
1 parent
3b6a873520
commit
8a9e70e90b
166 files changed
+18942
-1800
No files matched your search
+18
-10
@@ -1,5 +1,3 @@
|
||||
const grpc = require('@grpc/grpc-js');
|
||||
const protoLoader = require('@grpc/proto-loader');
|
||||
const { readFileSync } = require('fs');
|
||||
const { join } = require('path');
|
||||
|
||||
@@ -9,7 +7,7 @@ class GrpcClient {
|
||||
'config/grpc',
|
||||
);
|
||||
|
||||
static #loadTlsCredentials() {
|
||||
static #loadTlsCredentials(grpc) {
|
||||
try {
|
||||
return grpc.credentials.createSsl(
|
||||
readFileSync(join(GrpcClient.#certDir, 'ca.crt')),
|
||||
@@ -60,15 +58,22 @@ class GrpcClient {
|
||||
];
|
||||
|
||||
#client;
|
||||
#Metadata;
|
||||
#closed = false;
|
||||
#api = {};
|
||||
|
||||
constructor() {
|
||||
this.#initializeClient();
|
||||
this.#bindMethods();
|
||||
}
|
||||
|
||||
#initializeClient() {
|
||||
// The panel dependencies resolve as they did before the task's global-path hook.
|
||||
module.loadingPanelDependencies = true;
|
||||
try {
|
||||
// Resolve explicitly: Node can cache a previous task require by parent directory.
|
||||
const grpc = require(require.resolve('@grpc/grpc-js'));
|
||||
const protoLoader = require(require.resolve('@grpc/proto-loader'));
|
||||
this.#Metadata = grpc.Metadata;
|
||||
const { protoPath, protoOptions, serverAddress, grpcOptions } =
|
||||
GrpcClient.#config;
|
||||
|
||||
@@ -77,28 +82,30 @@ class GrpcClient {
|
||||
|
||||
this.#client = new apiProto.Api(
|
||||
serverAddress,
|
||||
GrpcClient.#loadTlsCredentials(),
|
||||
GrpcClient.#loadTlsCredentials(grpc),
|
||||
grpcOptions,
|
||||
);
|
||||
} catch (error) {
|
||||
console.error('Failed to initialize gRPC client:', error);
|
||||
process.exit(1);
|
||||
throw new Error('Failed to initialize gRPC client: ' + error.message, { cause: error });
|
||||
} finally {
|
||||
module.loadingPanelDependencies = false;
|
||||
}
|
||||
}
|
||||
|
||||
#promisifyMethod(methodName) {
|
||||
const capitalizedMethod =
|
||||
methodName.charAt(0).toUpperCase() + methodName.slice(1);
|
||||
const method = this.#client[capitalizedMethod].bind(this.#client);
|
||||
|
||||
return async (params = {}) => {
|
||||
if (this.#closed) throw new Error('Channel has been shut down');
|
||||
if (!this.#client) this.#initializeClient();
|
||||
return new Promise((resolve, reject) => {
|
||||
const metadata = new grpc.Metadata();
|
||||
const metadata = new this.#Metadata();
|
||||
const deadline = new Date(
|
||||
Date.now() + GrpcClient.#config.defaultTimeout,
|
||||
);
|
||||
|
||||
method(params, metadata, { deadline }, (error, response) => {
|
||||
this.#client[capitalizedMethod](params, metadata, { deadline }, (error, response) => {
|
||||
if (error) {
|
||||
return reject(error);
|
||||
}
|
||||
@@ -122,6 +129,7 @@ class GrpcClient {
|
||||
}
|
||||
|
||||
close() {
|
||||
this.#closed = true;
|
||||
if (this.#client) {
|
||||
this.#client.close();
|
||||
this.#client = null;
|
||||
|
||||
Reference in new issue
Block a user