我怎么知道Kestrel开始听音乐的时间? [英] How can I know when Kestrel has started listening?

查看:105
本文介绍了我怎么知道Kestrel开始听音乐的时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要通知systemd我的服务已成功启动,并且启动后需要运行的任务要求服务器已在目标Unix域套接字上正在侦听.

我正在使用IWebHost::Run来启动服务器,这是一个阻塞的调用.此外,我找不到任何明显的方法来设置委托或回调事件以成功初始化.

有人吗?

解决方案

您可以使用 SO帖子作为配置示例.

I need to notify systemd that my service has started up successfully, and a task it needs to run after startup requires that the server is already listening on the target Unix domain socket.

I am using IWebHost::Run to start the server, and that is a blocking call. Additionally, I am unable to find any obvious way to set a delegate or callback event for successful initialization.

Anyone?

解决方案

You may use Microsoft.AspNetCore.Hosting.IApplicationLifetime:

/// <summary>
/// Triggered when the application host has fully started and is about to wait
/// for a graceful shutdown.
/// </summary>
CancellationToken ApplicationStarted { get; }

Look into this SO post for the configuration example.

这篇关于我怎么知道Kestrel开始听音乐的时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆