[英]CrystalQuartz not working when running as windows service
I have added crystal quartz in my quartz scheduler project to show the dashboard ( check link ). 我在石英调度程序项目中添加了石英晶体,以显示仪表板( 请参见链接 )。 below code works fine when I am running the application as a console app.
当我将应用程序作为控制台应用程序运行时,以下代码可以正常工作。 but it does not work when we deploy it as windows service on the same machine.
但是当我们将其作为Windows服务部署在同一台计算机上时,它不起作用。 it's not even throwing any exception nor any log in event logger.
它甚至不会引发任何异常,也不会在事件记录器中进行任何登录。
IScheduler scheduler = SetupScheduler();
Action<IAppBuilder> startup = app =>
{
app.UseCrystalQuartz(scheduler);
};
Console.WriteLine("Starting self-hosted server...");
using (WebApp.Start("http://localhost:9000/", startup))
{
Console.WriteLine("Server is started");
Console.WriteLine();
Console.WriteLine("Check http://localhost:9000/quartz to see jobs information");
Console.WriteLine();
Console.WriteLine("Starting scheduler...");
scheduler.Start();
Console.WriteLine("Scheduler is started");
Console.WriteLine();
Console.WriteLine("Press [ENTER] to close");
Console.ReadLine();
}
Console.WriteLine("Shutting down...");
scheduler.Shutdown(waitForJobsToComplete: true);
Console.WriteLine("Scheduler has been stopped");
when we deploy the application as windows service I am getting below error while opening the link in the browser "This site can't be reached". 当我们将应用程序部署为Windows服务时,在浏览器中打开“无法访问此站点”链接时,出现以下错误。 but its working fine when we run it as a console.
但是当我们将其作为控制台运行时,它的工作正常。
finally, I solved it by replacing console.readline to below code 最后,我通过将console.readline替换为以下代码来解决了该问题
System.Threading.ManualResetEvent ojbManualResetEvent = new System.Threading.ManualResetEvent(false);
ojbManualResetEvent.WaitOne();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.