yiicod/yii2-cron

Auto block|unblock console command for the Yii2. One command without duplicate.

Installs: 29 500

Dependents: 6

Suggesters: 0

Security: 0

Stars: 7

Watchers: 2

Forks: 3

Open Issues: 1

Type:yii2-extension

1.1.2.1 2018-02-18 17:51 UTC

This package is auto-updated.

Last update: 2024-10-27 00:38:22 UTC


README

Latest Stable Version Total Downloads Scrutinizer Code QualityCode Climate

Provide a logic and functionality to block console commands until they execute. Unlocks commands exhibited at the expiration of the block if the server is down.

Usage

public function behaviors()
{
    return array(
        'LockUnLockBehavior' => array(
            'class' => 'yiicod\cron\commands\behaviors\LockUnLockBehavior',
            'timeLock' => 0 //Set time lock duration for command in seconds
        )
    );
}

Any command can be converted to daemon

class AwesomeCommand extends DaemonController
{
    /**
     * Daemon name
     *
     * @return string
     */
    protected function daemonName(): string
    {
        return 'mail-queue';
    }

    /**
     * Run send mail
     */
    public function worker()
    {
        // Some logic that will be repeateble 
    }
}