Open elvispdosreis opened 4 years ago
@elvispdosreis I am not sure I am following, you have 2 tasks running, you want one of the two to run only once, is that correct? And the second currently gets executed multiple times even though you are calling the onlyOne
?
You should check if the the lock files are being generated correctly, they're based on a signature of the function, it would be better to pass a custom identifier (https://github.com/peppeocchi/php-cron-scheduler#scheduling-jobs)
Just keep in mind that because you're using Closures, your tasks will run synchronously, so the second one will run after the first one is complete. My suggestion would be to call external scripts and schedule those external scripts so they can both run asynchronously.
To recap:
The scheduler is creating the lock file correctly with the task id, he is creating tasks
$scheduler->call(function (MercadoLivre $mercadolivre) {
$mercadolivre->messaging();
}, [$mercadolivre], 'mercadoLivre-messaging')->at('* * * * *')->then(function ($output) {
// ...
}, true)->onlyOne(ROOT_PATH . '/tmp');
however if I kill the process or he dies the lock file continues
this task will always be performed
I need the task to run only once until the end of the execution, even if the scheduler is called, this task should not be executed, before it ends
as it is today, it is always executed.