cosmicsafari Posted January 12, 2018 Share Posted January 12, 2018 Hi all, I have noticed that LazyCorn seems to run maybe once or twice and then just stops. Has anybody else encountered this, I have the following within 2 different modules. public function init(){ $this->addHookAfter('ProcessModule::executeEdit', $this, 'configurableButtons'); wire()->addHook('LazyCron::every15Minutes', $this, 'autoGenerate'); } public function init(){ wire('forms')->addHookAfter('ProcessModule::executeEdit', $this, 'configurableButtons'); wire()->addHook('LazyCron::everyHour', $this, 'getExport'); } Does having multiple LazyCrons setup cause any issues? Link to comment Share on other sites More sharing options...
netcarver Posted January 12, 2018 Share Posted January 12, 2018 LazyCron is driven by user visits. Are you sure the site is being visited regularly? If you need to guarantee a run, you need to setup a cron job to visit a page on your site, or simply use cron itself to drive your tasks. Another possibility is that the cron script is timing out behind the scenes and leaving the LC script jammed. 1 Link to comment Share on other sites More sharing options...
cosmicsafari Posted January 12, 2018 Author Share Posted January 12, 2018 31 minutes ago, netcarver said: LazyCron is driven by user visits. Are you sure the site is being visited regularly? If you need to guarantee a run, you need to setup a cron job to visit a page on your site, or simply use cron itself to drive your tasks. Another possibility is that the cron script is timing out behind the scenes and leaving the LC script jammed. The site has a regular flow of visitors so I don't suspect it is that, the timing out issue could be possible right enough. What would be the best way to un-jam it if thats the issue? Uninstall/Reinstall LazyCron? Link to comment Share on other sites More sharing options...
netcarver Posted January 12, 2018 Share Posted January 12, 2018 Hi @cosmicsafari Just look in the cache directory for a file called LazyCronLock.cache. If it is there for more than half a minute (or however long you estimate your code should run for) then delete it to unjam LazyCron. If this keeps happening, then there could be something in your hook method that is timing out and leaving the lock file there. Here's some code to return the location of the file if you want to do it programmatically... function getLazyCronLockfileName() { return wire('config')->paths->cache . "LazyCronLock.cache"; } 9 Link to comment Share on other sites More sharing options...
netcarver Posted February 7, 2021 Share Posted February 7, 2021 Update: Found out why LazyCron stops working sometimes. Have added an issue for the fix here. If you are using PHP7 or above, you can improve the reliability of LazyCron by wrapping your hook in a try {} catch (\Throwable $e) {} block. (Note the catch - it's a \Throwable, not an \Exception, so it catches errors as well as exceptions.) 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now