mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
⚡ Add hooks (#1053)
* ⚡ add 2 hooks * ⚡ Fix issue that if hook errors n8n would not shut down Co-authored-by: Jan Oberhauser <jan.oberhauser@gmail.com>
This commit is contained in:
@@ -70,6 +70,13 @@ export class Start extends Command {
|
|||||||
static async stopProcess() {
|
static async stopProcess() {
|
||||||
console.log(`\nStopping n8n...`);
|
console.log(`\nStopping n8n...`);
|
||||||
|
|
||||||
|
const externalHooks = ExternalHooks();
|
||||||
|
try {
|
||||||
|
await externalHooks.run('n8n.stop', []);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('There was an error in the "n8n.stop" hook.', error);
|
||||||
|
}
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
// In case that something goes wrong with shutdown we
|
// In case that something goes wrong with shutdown we
|
||||||
// kill after max. 30 seconds no matter what
|
// kill after max. 30 seconds no matter what
|
||||||
|
|||||||
@@ -413,7 +413,7 @@ export class ActiveWorkflowRunner {
|
|||||||
const returnFunctions = NodeExecuteFunctions.getExecuteTriggerFunctions(workflow, node, additionalData, mode);
|
const returnFunctions = NodeExecuteFunctions.getExecuteTriggerFunctions(workflow, node, additionalData, mode);
|
||||||
returnFunctions.emit = (data: INodeExecutionData[][]): void => {
|
returnFunctions.emit = (data: INodeExecutionData[][]): void => {
|
||||||
WorkflowHelpers.saveStaticData(workflow);
|
WorkflowHelpers.saveStaticData(workflow);
|
||||||
this.runWorkflow(workflowData, node, data, additionalData, mode);
|
this.runWorkflow(workflowData, node, data, additionalData, mode).catch((err) => console.error(err));
|
||||||
};
|
};
|
||||||
return returnFunctions;
|
return returnFunctions;
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -580,6 +580,7 @@ class App {
|
|||||||
newWorkflowData.updatedAt = this.getCurrentDate();
|
newWorkflowData.updatedAt = this.getCurrentDate();
|
||||||
|
|
||||||
await Db.collections.Workflow!.update(id, newWorkflowData);
|
await Db.collections.Workflow!.update(id, newWorkflowData);
|
||||||
|
await this.externalHooks.run('workflow.afterUpdate', [newWorkflowData]);
|
||||||
|
|
||||||
// We sadly get nothing back from "update". Neither if it updated a record
|
// We sadly get nothing back from "update". Neither if it updated a record
|
||||||
// nor the new value. So query now the hopefully updated entry.
|
// nor the new value. So query now the hopefully updated entry.
|
||||||
@@ -1907,6 +1908,6 @@ export async function start(): Promise<void> {
|
|||||||
console.log(`n8n ready on ${ADDRESS}, port ${PORT}`);
|
console.log(`n8n ready on ${ADDRESS}, port ${PORT}`);
|
||||||
console.log(`Version: ${versions.cli}`);
|
console.log(`Version: ${versions.cli}`);
|
||||||
|
|
||||||
await app.externalHooks.run('n8n.ready', []);
|
await app.externalHooks.run('n8n.ready', [app]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user