Files
Discount-Bandit/app/Console/Commands/DiscountFillSupervisorWorkersCommand.php
YNWA Fawzy f037a936f3 Fixes:
- fix type when filtering product by price met target.
- fix the lowest price was overridden if price wasn't crawled.
- fix store tabs not working
- fix some european amazon using "." as thousands separator.
- keep last 3 days of logs only.
- added volume to .env to fix 2FA not working after restarting container
- added volume for database
-

New Stores:
- best buy

New Features:

- add other users to the system and manage their tokens.
- add telegram notification.
- add percentage drop.
- robot detection for amazon ( if the system was detected as robot, it will stop executing and try the next product, the same product that was blocked will be crawled again in the next batch)

Took 6 hours 50 minutes
2024-09-29 18:31:13 +04:00

61 lines
1.4 KiB
PHP

<?php
namespace App\Console\Commands;
use App\Enums\StatusEnum;
use App\Models\Store;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\File;
use Illuminate\Support\Facades\Log;
class DiscountFillSupervisorWorkersCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'discount:fill-supervisor-workers';
/**
* The console command description.
*
* @var string
*/
protected $description = 'add stores workers to the supervisor config file';
/**
* Execute the console command.
*/
public function handle()
{
File::copy(base_path('docker/base_supervisord.conf') , '/etc/supervisor/conf.d/supervisord.conf');
Store::where("status" , StatusEnum::Published)->get()
->each(function ($store) {
Log::info($store->name . " appended");
File::append('/etc/supervisor/conf.d/supervisord.conf',
"
[program:laravel-worker-{$store->id}]
process_name=%(program_name)s_%(process_num)02d
user=root
command=php artisan queue:work --queue={$store->slug} --max-time=300 --sleep=1 --tries=1
autostart=true
autorestart=true
stopasgroup=true
killasgroup=true
numprocs=1
redirect_stderr=true
stdout_logfile=/var/log/worker.log
stopwaitsecs=300
");
});
}
}