Tuesday, May 23, 2017

proc_open() fork fails in Laravel controller

I get an error saying: proc_open(): fork failed - Cannot allocate memory in a Laravel controller. The generate function is called with axios (Vuejs SAP).

This is what my controller looks like

use Illuminate\Http\Request;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
use GifCreator\AnimGif;
use simpleimage\SimpleImage;
use Symfony\Component\Process\Process;
use Symfony\Component\Process\Exception\ProcessFailedException;

class GifController extends Controller
{
    //
    public function generate(Request $request)
    {
        if(!$request->ajax()) return;

        $cmd = 'ls';
        $process = new Process($cmd);
        $process->run();

        // executes after the command finishes
        if (!$process->isSuccessful()) {
            throw new ProcessFailedException($process);
        }

        echo $process->getOutput();        

    }
}

Any ideas?



via kmaar

Advertisement