Update n8n without interrupting running workflows (graceful shutdown)

Hi!

We are running a self-hosted n8n installation in queue mode with worker replicas managed by Docker Swarm.

When we update n8n, we do a docker pull n8nio/n8n:[TAG] in order to minimize the downtime, and env $(cat .env | xargs) docker stack deploy -c n8n-swarm.yml n8n in order to apply the update.

However, we don’t really know how does n8n handle this kind of update process in terms of gracefulness. I mean, what would happen to the workflow executions that has already started and are running at the time of the update?

If we need to update the server itself, should we stop all the containers with docker stop $(docker ps -a -q) and restart the server, or is there any kind of command we should send to n8n in order to let it shutdown gracefully?

Thanks!

1 Like

Hi @JavierCane, welcome to the community!

n8n would try to finish executions when shutting down (for up to 30s iirc) without the need to do anything manually. You can actually see it in the logs:

image

So using docker stop should be fine here :slight_smile:

1 Like

Awesome!

Thanks @MutedJam! :blush:

1 Like