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?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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_exithandler before requiring Sinatra.