Laravel Supervisord cannot create file

2019-08-01 12:11发布

问题:

I am using Laravel Supervisor as job for exporting excel file.
Normal action was successful when using
php artisan queue:work
The file was successfully generated in 'public/excel' directory.

But when using supervisor, the job was executed, but the file was not generated.
I've checked folder permission, it's already 0777.
Here is the config file. I'm doing exactly like in documentation

[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /home/xxxx/www/xxxx/artisan queue:work 
--sleep=3 --tries=3
autostart=true
autorestart=true
username=xxxx
password=xxxx
numprocs=8
redirect_stderr=true
stdout_logfile=/home/xxxx/www/xxxx/worker.log

Here's worker.log

[2017-12-08 20:44:42] Processing: App\Jobs\ExportExcel
[2017-12-08 20:44:44] Processed:  App\Jobs\ExportExcel

I have some command to write the database inside the ExportExcel job, and it's actually working fine. But the file is not generated. No error in laravel.log either

回答1:

After 10 hour of questioning should I quit job and open ice cream store, I found the solution(s) by:

-Laravel job '/' path doesn't refer to public therefore I move the exported data to storage path
https://laravel.io/forum/07-11-2014-file-permission-problems-in-queue-jobs

-Apparently server didn't use my updated code and still using old path. By using

php artisan config:clear
php artisan cache:clear

The cache will be cleared and new code will be used. Thanks to one of the comment from this video
https://youtu.be/_SndYcQvIuQ

-By the time I posted this question, the file was actually generated but in other folder, but the controller was refering to the new path from the old code so it doesn't find the file.

Cheers