HTTP4S / BLAZE / CATS效应是否有关闭挂钩
我正在使用带有CATS效果IO效果的Blaze后端运行HTTP4S服务器。我有一个事件记录仪,可以收集事件并定期冲洗它们以持续存储。我想确保队列中的任何事件在Sigterm关闭之前都被冲洗。
我已经尝试过
sys.ShutdownHookThread {
println("Flushing Event Reporter")
IO(flush).unsafeRunSync()
}
,但似乎没有运行,这可能是因为sys.shutdownhookthread
的Scaladoc指出,它可以“保证”运行。
我的问题是:我可以使用猫或HTTP4中的钩子吗?
我注意到,有一个 open Issue 在2018年的燃烧日期关于添加一个优雅的关闭时间计时器,但这并不能帮助我将关闭代码插入服务器生命周期。
I am running a http4s server using a blaze backend with cats-effect IO effects. I have an event logger that collects events and periodically flushes them to persistent storage. I'm wanting to ensure that any events in the queue are flushed before shutdown on SIGTERM.
I've tried
sys.ShutdownHookThread {
println("Flushing Event Reporter")
IO(flush).unsafeRunSync()
}
and this doesn't appear to run, possibly because the scaladoc for sys.ShutdownHookThread
states that it is "not guaranteed" to run.
My question is: is there a hook in cats or http4s that I can use instead?
I note that there is an open issue in blaze dating from 2018 about adding a graceful shutdown timer, but this doesn't help me insert the shutdown code into the server lifecycle.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论