Skip to content

Remove lock file of failed only-one callable job #142

@dmitry027

Description

@dmitry027

Hi,

I am trying to find out what should I do in case only-one callable job is failed:

$scheduler = new Scheduler();

$scheduler->call(function () {
    // ...
    throw new \Exception();
    // ...
}, [], 'job-id')->onlyOne();

$scheduler->run();

In this case lock file remains untouched and the job will not be executed again until I delete the lock file manually. I would like to change this behavior and let the job run again even if previous execution has failed. To do this I need to know the location of the lock file, but the Job class doesn't seem to provide that capability.

I ended up with the following hack:

foreach ($scheduler->getFailedJobs() as $failedJob) {
    unlink('/tmp/' . $failedJob->getJob()->getId() . '.lock');
}

Do you think it makes sense to allow the client code to access lock file path or maybe call removeLockFile() from the outside?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions