-
Notifications
You must be signed in to change notification settings - Fork 11k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Schedule runInBackground not fired #27541
Comments
I'll need more info and/or code to debug this further. Please post relevant code like models, jobs, commands, notifications, events, listeners, controller methods, routes, etc. You may use https://paste.laravel.io to post larger snippets or just reply with shorter code snippets. Thanks! |
Hi @driesvints . It`s just a simple command run in Kernel.php and a normal command file that write a x.txt in public_path with current date time. As i told, after i run So, if i copy / paste the command outputed by schedule:run, everything is working as expected. |
I don't have the means to test on Windows myself so hoping that someone on windows might be of help here. In the meantime you might have more luck on one of the support channels below. If you do confirm this as a bug please report back. |
I'll try tomorrow to install a fresh Laravel app, maybe on other Windows machine also and do this simpliest schedule / command test. And i`ll came back with news. |
@driesvints I come back with some conclusions. I installed a fresh laravel app and created a new command.
and in Kernel i have:
On
But command is not Fired! If i manualy run that outputed command, will executed it... And to exclude my PC, i installed same stuff on other clean Windows 10 PC and is same.. |
I'm running into the same issue. Laravel 5.7.28/PHP 7.2.7/Win10 Schedule:
Running
However, the command does not run. I don't think this is the correct syntax for spawning a background process on windows, based on this stackoverflow answer. I don't have much experience here, so I can't say for certain. |
Additionally, since Symfony Process spawns each process under When I test in my (cmd.exe) terminal, this doesn't seem to work:
(where but using quotes as suggested in a comment here does appear to work:
I haven't dug deep enough into the Laravel and Symfony Process combination to know whether the grouped command is being quoted this way for |
Ping. |
@Travis-Britz @oriceon currently a bit swamped and still no option to test on Windows. If you one of you two can whip up a PR with a fix, send it in and the other one confirm it we could merge that in. |
@Travis-Britz sure, it works with quotes but still not run as async. Does not respect that >NUL parameter.. For async it necessary start /B, and is fired OK from a cli.
So, it`s about Symfony Process. I changed \vendor\symfony\process\Process.php in prepareWindowsCommandLine method:
Then fired with:
but if i run, i get Now, if i set Why with bypass_shell false get that error code ? As i found, it means *** bypass_shell (windows only): bypass cmd.exe shell when set to TRUE |
Same issue for me! |
I found I workaround I'm using that works (for my needs) Inside the command I'm using a custom mutex (just install a third part package) that prevents the overlapping manually. In this way the after callback doesn't work as expected (it's run immediately, not waiting for task end), but I don't need it in this moment. Hope this helps someone before the bug is resolved |
For me the problem solved after I deleted the last & character from this line:
Before: Sadly as far as I can see the |
Guys, I made a fix that works for me on windows to run artisan commands in the background. // @islandblaze: Fix for Windows
if(windows_os()) {
return 'start /b cmd /c "(' . $event->command . ' & ' . $finished.')' . $redirect . $output . ' 2>&1"';
} I added a check for windows platform and executed the command in a new background process which will also notify Laravel once it's completed (via php artisan schedule:finish {id}). This also redirects any output from I cloned // config/app.php
'aliases' => [
...
'Illuminate\Console\Scheduling\CommandBuilder' =>
App\VendorCustom\Illuminate\Console\Scheduling\CommandBuilder::class,
], framework/src/Illuminate/Console/Scheduling/CommandBuilder.php Lines 54 to 57 in ada3503
App\VendorCustom\Illuminate\Console\Scheduling\CommandBuilder: ...
protected function buildBackgroundCommand(Event $event)
{
$output = ProcessUtils::escapeArgument($event->output);
$redirect = $event->shouldAppendOutput ? ' >> ' : ' > ';
$finished = Application::formatCommandString('schedule:finish').' "'.$event->mutexName().'"';
// @islandblaze: Fix for Windows
if(windows_os()) {
return 'start /b cmd /c "(' . $event->command . ' & ' . $finished.')' . $redirect . $output . ' 2>&1"';
}
// Original return statement for non-windows platforms
return $this->ensureCorrectUser($event,
'('.$event->command.$redirect.$output.' 2>&1 '.(windows_os() ? '&' : ';').' '.$finished.') > '
.ProcessUtils::escapeArgument($event->getDefaultOutput()).' 2>&1 &'
);
}
... I hope this helps someone. Cheers! |
* fixed #27541 * fixed wrong style * Update CHANGELOG-5.8.md * Update CommandBuilder.php
Description:
I`m on Windows 10 x64 System and trying to run a schedule, from cli, to run in background.
Running scheduled command is displayed but it does not fired.
If i copying it and running manualy it work like it should.
Any ideea what could be?!
Steps To Reproduce:
$schedule->command('my-command')->everyMinute()->runInBackground();
Running scheduled command: ("C:\php-7\php.exe" "artisan" my-command > "NUL" 2>&1 & "C:\php-7\php.exe" "artisan" schedule:finish "framework\schedule-47987621c9ff2fa8a91fa554f7471894a3325831") > "NUL" 2>&1 &
The text was updated successfully, but these errors were encountered: