Simmo
Simmo

Reputation: 1729

In Rails, how do I run certain tasks on shutdown?

I maintain a connection to a RabbitMQ server. When I safely turn the Rails Server off (via CTRL+C or whatever), how do I trigger a close to that connection?

I need an 'On shutdown' trigger. Is there one?

Upvotes: 1

Views: 277

Answers (1)

msbarnard
msbarnard

Reputation: 684

If you are using puma as your webserver you can add on_worker_shutdown as a callback and then execute a shell script or whatever else is needed to close the connection to RabbitMQ.

Upvotes: 4

Related Questions