简体   繁体   English

Quartz.Net Scheduler服务不会在启动时自动启动

[英]Quartz.Net scheduler service does not start automatically on startup

I have developed a Quartz.Net windows service to run scheduled jobs and I have set up an SQLite jobstore for it to work. 我已经开发了Quartz.Net Windows服务来运行计划的作业,并且我已经设置了SQLite作业存储来使其工作。 Here are the settings of my AdoJobStore : 这是我的AdoJobStore的设置:

# SQLite settings
quartz.jobStore.type = Quartz.Impl.AdoJobStore.JobStoreTX, Quartz
quartz.jobStore.misfireThreshold = 60000
quartz.jobStore.lockHandler.type = Quartz.Impl.AdoJobStore.UpdateLockRowSemaphore, Quartz
quartz.jobStore.useProperties = true
quartz.jobStore.dataSource = default
quartz.jobStore.tablePrefix = qrtz_
quartz.jobStore.driverDelegateType = Quartz.Impl.AdoJobStore.SQLiteDelegate, Quartz
quartz.dataSource.default.provider = SQLite-10
quartz.dataSource.default.connectionString = Data Source=.\jobs.db;Version=3

Before giving you a headache, I should say that this is a working solution! 在让您头痛之前,我应该说这是一个可行的解决方案! That means the job store works just fine! 这意味着工作商店就可以了! Each job consists of running an .exe file that will get its parameters from an SQL Server database using a connection string that is stored in a text file. 每个作业都包含运行一个.exe文件,该文件将使用存储在文本文件中的连接字符串从SQL Server数据库中获取其参数。

So if the service is started automatically, everything works fine. 因此,如果该服务自动启动,则一切正常。

After installing the Windows service, we give it a username that has access to the destination database in service's Log On tab. 安装Windows服务后,我们在服务的“ 登录”选项卡中为其提供一个可以访问目标数据库的用户名。 We set the service to start automatically (and have tried the Automatic Delayed mode as well). 我们将服务设置为自动启动(并尝试了“ 自动延迟”模式)。 In the Recovery tab of the service we also command it to Restart in case it crashes. 在服务的“ 恢复”选项卡中,我们还命令它在崩溃时重新启动

However, the service does not seems to be starting by itself on some machines and that has kept me wondering for quite a while now. 但是,该服务似乎并不是在某些机器上单独启动的,这让我想了很长时间。 On machines with failure, this is what my service logs when it fails to start: 在发生故障的计算机上,这是我的服务启动失败时记录的内容:

2015-02-13 15:09:15,674 [1] ERROR Quartz.Server.QuartzServer [(null)] - Server initialization failed:Unable to bind scheduler to remoting.
Quartz.SchedulerException: Unable to bind scheduler to remoting. ---> System.Net.Sockets.SocketException: No such host is known
   at System.Net.Dns.InternalGetHostByName(String hostName, Boolean includeIPv6)
   at System.Net.Dns.GetHostEntry(String hostNameOrAddress)
   at System.Runtime.Remoting.Channels.CoreChannel.GetMachineIp()
   at System.Runtime.Remoting.Channels.Tcp.TcpServerChannel.SetupMachineName()
   at System.Runtime.Remoting.Channels.Tcp.TcpServerChannel..ctor(IDictionary properties, IServerChannelSinkProvider sinkProvider, IAuthorizeRemotingConnection authorizeCallback)
   at System.Runtime.Remoting.Channels.Tcp.TcpChannel..ctor(IDictionary properties, IClientChannelSinkProvider clientSinkProvider, IServerChannelSinkProvider serverSinkProvider)
   at Quartz.Simpl.RemotingSchedulerExporter.RegisterRemotingChannelIfNeeded()
   at Quartz.Simpl.RemotingSchedulerExporter.Bind(IRemotableQuartzScheduler scheduler)
   at Quartz.Core.QuartzScheduler.Bind()
   at Quartz.Core.QuartzScheduler.Initialize()
   --- End of inner exception stack trace ---
   at Quartz.Core.QuartzScheduler.Initialize()
   at Quartz.Impl.StdSchedulerFactory.Instantiate()
   at Quartz.Impl.StdSchedulerFactory.GetScheduler()
   at Quartz.Server.QuartzServer.Initialize() [See nested exception: System.Net.Sockets.SocketException (0x80004005): No such host is known
   at System.Net.Dns.InternalGetHostByName(String hostName, Boolean includeIPv6)
   at System.Net.Dns.GetHostEntry(String hostNameOrAddress)
   at System.Runtime.Remoting.Channels.CoreChannel.GetMachineIp()
   at System.Runtime.Remoting.Channels.Tcp.TcpServerChannel.SetupMachineName()
   at System.Runtime.Remoting.Channels.Tcp.TcpServerChannel..ctor(IDictionary properties, IServerChannelSinkProvider sinkProvider, IAuthorizeRemotingConnection authorizeCallback)
   at System.Runtime.Remoting.Channels.Tcp.TcpChannel..ctor(IDictionary properties, IClientChannelSinkProvider clientSinkProvider, IServerChannelSinkProvider serverSinkProvider)
   at Quartz.Simpl.RemotingSchedulerExporter.RegisterRemotingChannelIfNeeded()
   at Quartz.Simpl.RemotingSchedulerExporter.Bind(IRemotableQuartzScheduler scheduler)
   at Quartz.Core.QuartzScheduler.Bind()
   at Quartz.Core.QuartzScheduler.Initialize()]

The service is installed on host 127.0.0.1 port 555 and does not seem to need a dependency because it works under some other machines. 该服务安装在主机127.0.0.1端口555 ,并且似乎不需要依赖,因为它在某些其他计算机上也可以运行。

I have a feeling that the service is trying to start itself before there is an access to the database or before the TCP host is established. 我有一种感觉,该服务在尝试访问数据库或建立TCP主机之前尝试启动自身。 But if that's the case, why does it work on other devices? 但是,如果是这样,为什么它可以在其他设备上运行?

I have asked the same question before but have failed to find a working answer. 我之前曾问过同样的问题,但没有找到有效的答案。 Any help from Quartz.Net dev team or Windows Services experts is greatly appreciated. 非常感谢Quartz.Net开发团队或Windows服务专家的任何帮助。

Disclaimer. 免责声明。 I'm not part of the Quartz.net dev team, nor am I an expert on Windows services 我不是Quartz.net开发团队的成员,也不是Windows服务的专家

The service is installed on host 127.0.0.1 port 555 and does not seem to need a dependency because it works under some other machines. 该服务安装在主机127.0.0.1端口555上,并且似乎不需要依赖,因为它在某些其他计算机上也可以运行。

Your reasoning is false. 您的推论是错误的。 It could be that the required services just happen to have always started on the other machines, but without setting a dependency this is not guaranteed. 这可能是因为所需的服务恰好一直开始在其他机器,但没有设置这个不能保证的依赖。

So, since you are getting a DNS error, I would suggest you start by setting your service do that it depends on Dnscache and Tcpip . 因此,由于您遇到了DNS错误,因此建议您首先将服务设置为取决于DnscacheTcpip

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM