Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

where do I put code in Sinatra that I want to execute when the app is shutdown?

Tags:

ruby

sinatra

I am using Sinatra for my webapp. I have some cleanup code that I want to execute when my app is being shutdown. Is there a hook for this in Sinatra or do I have to use a separate mechanism?

like image 283
pquimo Avatar asked Jun 19 '12 16:06

pquimo


1 Answers

Look at Kernel#at_exit, I don't see why it shouldn't work in a Sinatra app if you define a block like that somewhere in your main app file.

Update: According to matt's comment, you have to define your at_exit handler before requiring Sinatra.

like image 190
Michael Kohl Avatar answered Nov 03 '22 06:11

Michael Kohl