I am working on projects where the CronJob works are being handelled by a console commands. Those commands are developed manually to serve different jobs on the DB.
But now the issue is When we run
php artisan cache:clear
it checks all commands created under console folder first and then its running the cache:clear
command. So obviously the command is running super slow. because its going through 15 commands that has been created manually.
So Is there a way we can ignore those manual command while running migration , cache , config , view commands. And those commands only being active when we call it manually ?
I have checked using making it hidden using following method but it didnt work
Hiding Using the Command hidden property
class updateAPILogSync extends Command
{
protected $signature = 'apilog:update';
protected $description = 'Serve function to sync the log to migrant DB';
protected $hidden = true;
}
Hiding Using the setHidden method
class updateAPILogSync extends Command
{
protected $signature = 'apilog:update';
protected $description = 'Serve function to sync the log to migrant DB';
public function __construct()
{
parent::__construct();
$this->setHidden(true);
}
}
Can please guide me on this. how i can ignore this manual commands and speed up the pre-defined commands
CodePudding user response:
Please check your commands and see if those are jobs are being performed from the constructor.
if its loading from the constructor then it will be running when any command is being executed. because it builds every command when we run any command from cli. so just move it to the handle()
instead of __construct()
CodePudding user response:
you can try making your own implementation of how it registers commands https://laravel.com/docs/8.x/artisan#registering-commands