Scheduled Tasks afte Restart


#1

Would love some help with an issue we are having with lucee scheduled tasks (standard tomcat + apache configuration using mod_cfml).

Whenever lucee restarts (which is every morning for our dev machines), the scheduled tasks do not fire until the website is hit.
From what I can see they are not firing until the context is loaded in tomcat, which doesn’t happen until you hit any url for the site.

Is there a way to fire these scheduled tasks regardless of the tomcat context, or to automatically load all contexts when restarting lucee+tomcat?

It can be a big issue when you have multiple scheduled tasks on multiple applications/contexts!

Lucee 5.2.9.31
Tomcat 8.5.31
Apache 2.4.18
Ubuntu 16.04.5 LTS


#2

Hi @bgibson,

I’ve checked with lucee 5.2.9.31 , Tomcat 8.5.31, windows 10. After restart the server scheduled task works fine for me.


#3

I suspect it’s a Linux/mod_cfml only problem.


REST service not starting at server startup
#4

Yes. You can edit your Tomcat server.xml file (C:\lucee\tomcat\conf\server.xml) and add your sites to the bottom of it. There are comments there that show you how. This will load your context at startup rather than on the fly using mod_cfml.

Another option would be to configure your scheduled tasks to follow 301 redirects. After mod_cfml creates a context on the fly, it will issue a 301 redirect response so that the client will re-issue the request to the right context. Since the first request was to the wrong context (the right context didn’t exist yet), there’s no way for mod_cfml to fulfill that request correctly, so it must be re-issued. If your scheduled tasks do not follow this 301 redirect, they will not run. This is what you are experiencing.

Either of these methods will address this problem.