Scheduled Tasks afte Restart

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!

Tomcat 8.5.31
Apache 2.4.18
Ubuntu 16.04.5 LTS

Hi @bgibson,

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

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

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.

1 Like