mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 10:31:15 +00:00
refactor(core): Bundle the go based launcher to the n8n docker image (no-changelog) (#11792)
Co-authored-by: Iván Ovejero <ivov.src@gmail.com>
This commit is contained in:
@@ -42,10 +42,6 @@ export class TaskRunnerProcess extends TypedEmitter<TaskRunnerProcessEventMap> {
|
||||
return this._runPromise;
|
||||
}
|
||||
|
||||
private get useLauncher() {
|
||||
return this.runnerConfig.mode === 'internal_launcher';
|
||||
}
|
||||
|
||||
private process: ChildProcess | null = null;
|
||||
|
||||
private _runPromise: Promise<void> | null = null;
|
||||
@@ -99,9 +95,7 @@ export class TaskRunnerProcess extends TypedEmitter<TaskRunnerProcessEventMap> {
|
||||
const grantToken = await this.authService.createGrantToken();
|
||||
|
||||
const n8nUri = `127.0.0.1:${this.runnerConfig.port}`;
|
||||
this.process = this.useLauncher
|
||||
? this.startLauncher(grantToken, n8nUri)
|
||||
: this.startNode(grantToken, n8nUri);
|
||||
this.process = this.startNode(grantToken, n8nUri);
|
||||
|
||||
forwardToLogger(this.logger, this.process, '[Task Runner]: ');
|
||||
|
||||
@@ -116,16 +110,6 @@ export class TaskRunnerProcess extends TypedEmitter<TaskRunnerProcessEventMap> {
|
||||
});
|
||||
}
|
||||
|
||||
startLauncher(grantToken: string, n8nUri: string) {
|
||||
return spawn(this.runnerConfig.launcherPath, ['launch', this.runnerConfig.launcherRunner], {
|
||||
env: {
|
||||
...this.getProcessEnvVars(grantToken, n8nUri),
|
||||
// For debug logging if enabled
|
||||
RUST_LOG: process.env.RUST_LOG,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@OnShutdown()
|
||||
async stop() {
|
||||
if (!this.process) return;
|
||||
@@ -133,11 +117,7 @@ export class TaskRunnerProcess extends TypedEmitter<TaskRunnerProcessEventMap> {
|
||||
this.isShuttingDown = true;
|
||||
|
||||
// TODO: Timeout & force kill
|
||||
if (this.useLauncher) {
|
||||
await this.killLauncher();
|
||||
} else {
|
||||
this.killNode();
|
||||
}
|
||||
this.killNode();
|
||||
await this._runPromise;
|
||||
|
||||
this.isShuttingDown = false;
|
||||
@@ -147,11 +127,7 @@ export class TaskRunnerProcess extends TypedEmitter<TaskRunnerProcessEventMap> {
|
||||
async forceRestart() {
|
||||
if (!this.process) return;
|
||||
|
||||
if (this.useLauncher) {
|
||||
await this.killLauncher(); // @TODO: Implement SIGKILL in launcher
|
||||
} else {
|
||||
this.process.kill('SIGKILL');
|
||||
}
|
||||
this.process.kill('SIGKILL');
|
||||
|
||||
await this._runPromise;
|
||||
}
|
||||
@@ -162,24 +138,6 @@ export class TaskRunnerProcess extends TypedEmitter<TaskRunnerProcessEventMap> {
|
||||
this.process.kill();
|
||||
}
|
||||
|
||||
async killLauncher() {
|
||||
if (!this.process?.pid) {
|
||||
return;
|
||||
}
|
||||
|
||||
const killProcess = spawn(this.runnerConfig.launcherPath, [
|
||||
'kill',
|
||||
this.runnerConfig.launcherRunner,
|
||||
this.process.pid.toString(),
|
||||
]);
|
||||
|
||||
await new Promise<void>((resolve) => {
|
||||
killProcess.on('exit', () => {
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private monitorProcess(taskRunnerProcess: ChildProcess) {
|
||||
this._runPromise = new Promise((resolve) => {
|
||||
this.oomDetector = new NodeProcessOomDetector(taskRunnerProcess);
|
||||
|
||||
Reference in New Issue
Block a user