In one of our laravel project in windows environment, we need a queue listener. So at the start we passed the following command in command prompt and that window remain opened.
C:\Apache24\htdocs\laravel\artisan queue:listen --timeout=240
But it's not a good move because if anyone mistakenly closed or after system update it may close. So we planned for background process with scheduler.
We run a batch file during system startup and every 1 hour. The batch has the following command.
start /MIN /B php C:\Apache24\htdocs\laravel\artisan queue:listen --timeout=240
But after a few days once we explored task manager we noted that there were many PHP CLI running in background process resulted in 100% process used. The System got slowdown. So we additionally added command to kill already running PHP CLI. The batch file was resembled like the given below commands.
taskkill /f /fi "imagename eq php.exe"
start /MIN /B php C:\Apache24\htdocs\laravel\artisan queue:listen --timeout=240
Now we need to run another background process with the interval of 1 minute. If it runs every minute then new PHP CLI background process will be started. If we kill all past PHP CLI background process it will kill already running PHP CLI for artisan queue
.
So for this dependency what would be the best approach to resolve this issue.
Our main target is there won't be any orphaned PHP CLI background process running which consumes more memory.