I have a gearman server, that has a php worker-script in background (managed by supervisord). The process is asynchronous, so the main script does not have to wait.
The problem is that I do not need the worker 100% of the time in background, I only need it when there is a job for the worker. Is there any way to avoid background php process? e.g. some script that will monitor incoming tasks and execute appropriate php files?
The solution I have in mind is to create a shell scipt that will execute php code, something like:
gearman -w -f 'my_func' ./my_func_exec.sh
where my_func_exec.sh:
php -q my_func.php
But how should I pass workload to my_func.php? Or are there ready-made solutions?