Jump to content

Lazycron Hooks


ZGD
 Share

Recommended Posts

I've looked through the forum and various issues on Github and can't seem to find a definitive answer for this.

It seems some Lazycron hooks have stopped working reliably on one of my PW installations. The function which adds the hooks is triggered successfully every minute and logs a message (I've tested the cronjob and it is working correctly), however it seems the hook itself is being very temperamental. This line in the module's init method should add a hook for every minute:

$this->addHook("LazyCron::everyMinute", $this, 'myFunction');

The first line of myFunction logs a string whenever it is executed, before doing anything else. I've been watching the module log all day and this function seems to execute each minute up to around 5 times, and then stops executing. I've been monitoring the site's cache folder, and sometimes deleting the LazyCron.cache file resolves the problem temporarily, other times it does not. Sometimes if I leave everything alone for a few hours, myFunction starts executing again. Unlike other people who have reported similar issues, I don't have have a LazyCronLock.cache file that is causing problems.

I can't work this one out, has anyone encountered something similar?

Link to comment
Share on other sites

I had a similar problem to this when I wrote a module for a client. It turned out that having a tab open on the module's log page stopped the hook from firing, even though I had a cron job, running every minute, visiting a page on the site. As far as I can tell, the auto refresh that occurs on the log pages somehow stops the hook from triggering.

Once I closed the log view page, I could watch things go back to normal just be looking at the actual log file from the command line using the 'tail -f' command.

The solution for me was to only open the log pages when needed and provide my own view of the log tail as part of the module's settings page.

HTH

  • Like 2
Link to comment
Share on other sites

  • 1 month later...
On 07/10/2016 at 6:52 AM, netcarver said:

I had a similar problem to this when I wrote a module for a client. It turned out that having a tab open on the module's log page stopped the hook from firing, even though I had a cron job, running every minute, visiting a page on the site. As far as I can tell, the auto refresh that occurs on the log pages somehow stops the hook from triggering.

Thanks netcarver, will try this on a LazyCron hook that doesn't fire as expected. Hook is in API/page template, not module. Have been trying to figure out the problem for ages. It fired once, and once only... LazyCron times are recorded as expected in assets/cache/LazyCron.cache but nothing ever happens.

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...