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

强颜欢笑 提交于 2021-02-08 12:52:27

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/11105556/where-do-i-put-code-in-sinatra-that-i-want-to-execute-when-the-app-is-shutdown

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!