IIS 托管工作流服务如何检测应用程序启动和停止

发布于 2024-12-05 08:26:41 字数 189 浏览 3 评论 0原文

我想挂钩应用程序启动和停止事件来跟踪我的 IIS 托管工作流服务是否正在运行。理想情况下,当我通过启动 AppPool 或 IIS 应用程序(如果多个服务共享同一个 AppPool)来启动工作流服务时,我希望将事件记录到数据库中。当我通过停止 AppPool 或 IIS 应用程序来停止工作流服务时,我想将事件记录到数据库中。

有办法做到这一点吗?

I want to hook into the application start and stop events to track whether my IIS Hosted Workflow Services are running. Ideally, when I start my workflow service via starting the AppPool or the IIS Application (if multiple services share the same AppPool), I want to log an event into a database. And when I stop my workflow service via stopping the AppPool or the IIS Application, I want to log an event into the database.

Is there a way to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

∞琼窗梦回ˉ 2024-12-12 08:26:42

您应该查看有关 Windows Server AppFabric 的这篇文章。具体来说,请查看“跟踪的 WF 事件”部分。

http://msdn.microsoft.com/en- us/library/ee677205(v=azure.10).aspx

AppFabric 是单独安装的(http://msdn.microsoft.com/en-us/library/ff637745(v=azure.10).aspx),但我认为这将有助于帮助您实现有关工作流和服务监控的目标。

安装 AppFabric

You should check out this article on Windows Server AppFabric. Specifically, take a look at the section on "Tracked WF Events".

http://msdn.microsoft.com/en-us/library/ee677205(v=azure.10).aspx

AppFabric is a separate install (http://msdn.microsoft.com/en-us/library/ff637745(v=azure.10).aspx), but I think it will go a long way towards helping you accomplish your objectives regarding workflow and service monitoring.

Install AppFabric

谁对谁错谁最难过 2024-12-12 08:26:42

我的意见是 Application_Start & Application_End 在应用程序生命周期中执行得太早(或太晚),我认为诸如 DataBase Access 对象之类的东西将不可供您使用。

我的建议是使用文件系统来交换数据。

 void Application_Start(object sender, EventArgs e) 
    {
        // Code that runs on application startup
        FileStream fs = new FileStream(@"D:\something\hello.txt", FileMode.Append);
        StreamWriter sw = new StreamWriter(fs);
        sw.WriteLine(DateTime.Now.ToString());
        sw.Flush();
        fs.Close();

    }

这会将您想要的任何内容写入文本文件,然后您可以使用简单的服务读取该文件并获取相关数据。

My opinion is that Application_Start & Application_End are executed too early (or too late) during the application life-cycle and I assume that things like DataBase Access object will not be available for you use.

My recommendation is to use FileSystem to exchange the data.

 void Application_Start(object sender, EventArgs e) 
    {
        // Code that runs on application startup
        FileStream fs = new FileStream(@"D:\something\hello.txt", FileMode.Append);
        StreamWriter sw = new StreamWriter(fs);
        sw.WriteLine(DateTime.Now.ToString());
        sw.Flush();
        fs.Close();

    }

This will write anything you want into a text file, which you can then read with a simple service and fetch the relevant data.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文