mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 10:31:15 +00:00
feat: Forward logs from task runner to logger (no-changelog) (#11422)
This commit is contained in:
@@ -4,8 +4,11 @@ import { spawn } from 'node:child_process';
|
||||
import * as process from 'node:process';
|
||||
import { Service } from 'typedi';
|
||||
|
||||
import { OnShutdown } from '@/decorators/on-shutdown';
|
||||
import { Logger } from '@/logging/logger.service';
|
||||
|
||||
import { TaskRunnerAuthService } from './auth/task-runner-auth.service';
|
||||
import { OnShutdown } from '../decorators/on-shutdown';
|
||||
import { forwardToLogger } from './forward-to-logger';
|
||||
|
||||
type ChildProcess = ReturnType<typeof spawn>;
|
||||
|
||||
@@ -38,6 +41,8 @@ export class TaskRunnerProcess {
|
||||
|
||||
private isShuttingDown = false;
|
||||
|
||||
private logger: Logger;
|
||||
|
||||
private readonly passthroughEnvVars = [
|
||||
'PATH',
|
||||
'NODE_FUNCTION_ALLOW_BUILTIN',
|
||||
@@ -45,6 +50,7 @@ export class TaskRunnerProcess {
|
||||
] as const;
|
||||
|
||||
constructor(
|
||||
logger: Logger,
|
||||
private readonly runnerConfig: TaskRunnersConfig,
|
||||
private readonly authService: TaskRunnerAuthService,
|
||||
) {
|
||||
@@ -52,6 +58,8 @@ export class TaskRunnerProcess {
|
||||
this.runnerConfig.mode === 'internal_childprocess' ||
|
||||
this.runnerConfig.mode === 'internal_launcher',
|
||||
);
|
||||
|
||||
this.logger = logger.scoped('task-runner');
|
||||
}
|
||||
|
||||
async start() {
|
||||
@@ -64,8 +72,7 @@ export class TaskRunnerProcess {
|
||||
? this.startLauncher(grantToken, n8nUri)
|
||||
: this.startNode(grantToken, n8nUri);
|
||||
|
||||
this.process.stdout?.pipe(process.stdout);
|
||||
this.process.stderr?.pipe(process.stderr);
|
||||
forwardToLogger(this.logger, this.process, '[Task Runner]: ');
|
||||
|
||||
this.monitorProcess(this.process);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user