1

I've implemented quartz.net in windows service to run tasks. And everything works fine on local workstation. But once it's deployed to remote win server host, it just hangs after initialization.

ISchedulerFactory schedFact = new StdSchedulerFactory();

// get a scheduler
var _scheduler = schedFact.GetScheduler();

// Configuration of triggers and jobs
var trigger = (ICronTrigger)TriggerBuilder.Create()
                                          .WithIdentity("trigger1", "group1")
                                          .WithCronSchedule(job.Value)
                                          .Build();

var jobDetail = JobBuilder.Create(Type.GetType(job.Key)).StoreDurably(true)
                                .WithIdentity("job1", "group1").Build();

var ft = _scheduler.ScheduleJob(jobDetail, trigger);

Everything seems to be standard. I have private static pointer to scheduler, logging process stops right after jobs are initialized and added to scheduler. Nothing else happens after. I'd appreciate any advices.

Thanks.

PS:

Found some strange events in event viewer mb according quartz.net:

Restart Manager - Starting session 2 - ‎2012‎-‎07‎-‎09T15:14:15.729569700Z.
Restart Manager - Ending session 2 started ‎2012‎-‎07‎-‎09T15:14:15.729569700Z.
Jehof
  • 34,674
  • 10
  • 123
  • 155
Johnny_D
  • 4,592
  • 3
  • 33
  • 63
  • So are you saying the service properly starts and then just doesn't execute jobs? Or the service hangs and doesn't give you the "sucessfully started" message (assuming you are running from cmd) – Phillip Schmidt Jul 09 '12 at 14:40
  • I even refactored code to run it as console app instead of service. Scheduler behaves very strange, I even can't close app properly, only via process kill. Seems that scheduler start some operation and hangs. – Johnny_D Jul 09 '12 at 15:02
  • First thing you should do then is check windows logs to see if the service is being properly initialized. Go to start menu and find "Event Viewer", go to windows logs, application, sort by date/time, find ones with the source matching your service, and let me know what the logs say – Phillip Schmidt Jul 09 '12 at 15:23
  • most of the time you can't end the process, it's because it hangs on the onStart or onStop event of the service, during which the service won't respond to events. As a general rule, leave any heavy lifting or error-prone code out of onStart – Phillip Schmidt Jul 09 '12 at 15:25
  • throw a try/catch around the code above and then repeat the event viewer process, and you'll get a more detailed description of what's going on – Phillip Schmidt Jul 09 '12 at 15:27
  • give me a little bit, I'm exploring restart manager now. Not an expert on it at all, but I know that it is packed with certain types of programs by default and is a tool for stopping and starting services even when they aren't responding or are using files. It's also an API that can be used by developers for custom actions. I would guess that you didn't specifically add any restart manager functionality though, am I correct? – Phillip Schmidt Jul 09 '12 at 15:39
  • Ok, so restart manager sessions are started when trying to `install` programs, and is used to reduce the number of system restarts needed. Basically, if the program you are trying to install needs to use a file or service that is already in use, Restart manager tries to use the files anyway so that you don't need to restart to install your service. The fact that it is running leads me to believe that unless your service is installing other programs, you probably have a problem with your service installer. – Phillip Schmidt Jul 09 '12 at 15:57
  • What I would do is convert it back to a win service and try installing it via installutil. Let me know what errors arise from doing that. – Phillip Schmidt Jul 09 '12 at 15:57
  • @PhillipSchmidt, no I didn't add any restarn manager functionality, I thought it comes from quartz.net. As a web service after install util it also behaves the same. It hangs... Maybe this behaviour from log4net rolling appender? – Johnny_D Jul 10 '12 at 06:48
  • @PhillipSchmidt, can you write your advices as answer, because they really helped me to solve problem, so I can mark them as answer. – Johnny_D Jul 10 '12 at 11:12

2 Answers2

2

Based on your question and the additional info you gave in comments, I would guess there is something going wrong in the onStart method of your service.

Here are some things you can do to help figure out and solve the problem:

  1. Place the code in your onStart method in a try/catch block, and try to install and start the service. Then check windows logs to see if it was installed correctly, started correctly, etc.
  2. The fact that restart manager is running leads me to believe that your service may be dependent on a process which is already in use. Make sure that any dependencies of your service are closed before installing it.
  3. This problem can also be caused by putting data-intense or long running operations in your onStart method. Make sure that you keep this kind of code out of onStart.
Phillip Schmidt
  • 8,805
  • 3
  • 43
  • 67
0

I had a similar problem to this and it was caused by having dots/periods in the assembly name e.g. Project.Update.Service. When I changed it to ProjectUpdateService it worked fine.

Strangely it always worked on the development machine. Just never on the remote machine.

UPDATE: It may have been the length of the service that has caused this issue. By removing the dots I shortened the service name. It looks like the maximum length is 25 characters.

Remotec
  • 10,304
  • 25
  • 105
  • 147