Skip to content

Initialisation is slow #9

@ikkez

Description

@ikkez

\Cron::instance(); is slow, because it always calls the binary method which uses an exec call:

f3-cron/lib/cron.php

Lines 54 to 56 in a66f447

function binary($path) {
if (function_exists('exec')) {
exec($path.' -v 2>&1',$out,$ret);

this cant be skipped, even if you'd set a valid path. Some measurements showed a bottleneck here:

Bildschirmfoto 2020-01-08 um 18 29 53

Would love to see some way of avoiding this path check with each and every page load. For now I'm using this workaround:

if ($this->fw->CLI ||
	($this->fw->exists('CRON.web',$web) && $web 
		&& preg_match('/^\/cron\/.*/',$this->fw->PATH)))
	\Cron::instance();

This way it's only called when the cron service is really used. Maybe it could fit into its contruct as well 🤔
thx bro ;)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions