1

I want to process my script in background on Laravel.

My code:

File::findOrFail($id, ['id']);

try {
    $process = new Process('php ../artisan api:get-products ' . $id);
    $process->start();
} catch (\Exception $e) {
    $log = new Logger('API');
    $log->pushHandler(new StreamHandler(storage_path('logs') . '/api.log'));
    $log->error('Error', ['error' => $e->getMessage()]);

    return back()->withErrors('Ошибка при постановки скрипта в фон');
}

\Flash::success('Wait data');

return back();

On Laravel Homestead VM it works fine. But on production server background script doesn't work. It works only with run() method.

luchaninov
  • 6,792
  • 6
  • 60
  • 75
J.Menshov
  • 83
  • 6
  • What does it mean, it doesn't work? What happens? Does it retrieve the file by the id? Would also benefit if said what is the expected output. – Mihkel Allorg May 18 '16 at 11:50
  • Without more information about the error you're seeing, I would guess it has some to do with your relative path to artisan... instead "php ../artisan" try to the full path to artisan "php /var/www/project/artisan ..." – AndyBeeSee May 26 '16 at 20:18

0 Answers0