Closed Pilskalns closed 6 years ago
Hmm... and is there practical reason why plugin is not calling beforeRoute()
of routed class? :)
Hi @Pilskalns,
it's not possible at the moment but I guess it should be possible to add an option, like /cron?async=false
.
May I ask why you need to run all tasks synchronously?
is there practical reason why plugin is not calling beforeRoute()
Sure: the plugin is not doing any routing ^^
Routing is the process of mapping each web resource to a piece of code. That's what is happening when you call $f3->run()
.
This plugin is doing something different: it executes due tasks. There's no routing involved.
May I ask why you need to run all tasks synchronously?
I develop on Windows, async mode not working with /cron
. When using /cron/@jobID
it forces for specific task sync mode and works. But then it looses point of using scheduled timing from config.
When calling in async mode from CLI, I get error, which comes somewhere from PHP itself:
The process cannot access the file because it is being used by another process.
beforRoute()
Thanks for the clarification. I use it to setup database connections, hive keys etc. common things to autoloaded class.Then I guess __construct()
for autoloaded class be better place for it. Though currently did workaround adding self::beforeRoute($f3);
to functions called from f3-cron.
P.S. /cron?async=false
does not get mapped trough up to run()
function in f3-cron
.
Though I can try make this working and then do PR.
So if I understand you well, you need sync mode only because async mode fails on Windows.
I'll check if I can have async mode work on Windows and if not, I'll disable it.
For now, to do all tasks in sync mode I was able to do simple fix, which works both - CLI and web.
Hi @xfra35,
I have put previous and Windows async feature on forked branch
Everything works from CLI and web. I have two tasks working with DB:
Hi @Pilskalns,
I just added support for Windows to the plugin. Can you download the latest release and see if it fixes it up?
Having async mode working on Windows, you shouldn't need the sync flag anymore.
Hello @xfra35,
Technically it works, but it flashes a window for each async task run. It stays open until task finished. It can be suppressed by using adding background switch like start /b
to start
command.
Thanks for reporting. Fixed in https://github.com/xfra35/f3-cron/commit/af0b4fd81b2d8d129da32a70ec0adbb4bc66eee0
Hi,
I try to develop from Windows (will be hosting on Unix), but plugin tries to run tasks in
async
mode. Is there a way to force run all tasks insync
mode?I have tried both
php index.php /cron
and trough browserhttp://local.domain/cron