xasharma there are different ways to make a server run a PHP script as a daemon.
Laravel recommends using Supervisor which should be available on many Linux operating systems. They show an example config file in their documentation https://laravel.com/docs/6.x/queues#supervisor-configuration Just adjust the command=
instruction for Flarum (adjust path, executable name and remove queue driver from parameters), something like command=php /home/forge/app.com/flarum queue:work --sleep=3 --tries=3
. You can probably drop the --sleep
and --tries
parameters as well if you don't want to customize them.
Personally I manage my VPSes with Laravel Forge and they have a nice utility where I can just drop the flarum queue:work
command and it sets up Supervisor for me.
There are many other Linux service managers that could be used in place of Supervisor. If your hosting is managed it might come with another built-in option. Usually those services ask for parameters like a command to run, a number of processes to run, whether to auto-restart the script if it crashes and how long to wait before restarts or when to kill the process if it takes too long to stop. It's probably fine to run just one process for the queue worker but if your server has a lot of resources you can start more processes.
If you need more help, please describe your exact hosting situation in detail.