dmitry-ivanov / laravel-helper-functions Goto Github PK
View Code? Open in Web Editor NEWLaravel-specific and pure PHP Helper Functions.
License: MIT License
Laravel-specific and pure PHP Helper Functions.
License: MIT License
I run about 1M+ background processes in a day using background process from a single initiator. Lots of time call_in_background throws "exec() unable to fork" error, though I have set all ulimit as was suggested in forums.
I recommend to implement proc_open instead of exec. Maybe provide this as an optional feature in the code.
Here's what I updated in BackgroundCommand.php, it fixed the issue for me. Ref https://bugs.php.net/bug.php?id=18833
Also if anyone has any idea why exec throws this error on background_call, please let me know :)
...
public function run(& $result,& $status){
$command = $this->composeCommand();
$command = is_windows_os()
? "start /B {$command}"
: "({$command}) > /dev/null 2>&1 &";
$process = proc_open(
$command,
array(
0 => array("pipe", "r"), //STDIN
1 => array("pipe", "w"), //STDOUT
2 => array("pipe","w")), //STDERR
$pipes
);
$result = stream_get_contents($pipes[1]);
$error = stream_get_contents($pipes[2]);
fclose($pipes[1]);
fclose($pipes[2]);
$status= proc_close($process);
$result = explode("\n",trim($result));
return($error);
}
При запуске команды call_in_background на Windows выполнение команды не происходит, видимо из-за
protected function composeForRunInBackground()
{
return "({$this->composeForRun()}) > /dev/null 2>&1 &";
}
Так как разрабатывать и отлаживать приходится в ОС Windows, то это не очень-то удобно.
Hello, I tried using call_in_background() in Lumen, but the command fails because it tries to run it from the /public folder instead of the application root and outputs "Could not open input file: artisan".
I think the function should try to run the command from the app root, not public folder.
Hi,
this is a very good helper function, but i can't make it to work on Laravel 5.5
Calling the call_in_background('UpdateProductPrice:updateproductprice')
is not triggering artisan command.
Could you check please and let me know how to debug this ?
Thank you!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.