Akanksha Mehrotra
Akanksha Mehrotra

Reputation: 1

Monitoring php Scripts through Gearman

I am trying to run my php scripts in Gearman worker code but also want to monitor besides that if they are taking more than the expected run time ,I want to kill those scripts.Each script has to run in a timely fashion(say running every 10 minutes) and the Gearman client picks ,the script which are ready to run and send s them to Gearman worker.

I tried using the following options :

1) Tried using an independent script,a normal php script which monitors the running process. But this normal scripts will not inform Gearman that job got killed and Gearman thinks that the job that got killed is still running.

So that made me think I have to synchronize the process of monitoring and process of running php scripts in the same worker. Also these jobs need to be restarted and the client takes care of them.

2) I am running my php scripts using the following command : cd /home/amehrotra/include/core/background;php $workload;(this is blocking does not go to the next line until the script finishes execution).

I tried using exec , but exec does not execute the scripts exec ("/usr/bin/php /home/amehrotra/include/core/background/$workload >/dev/null &");

3) Tried running 2 workers ,one for running php script another for monitoring but Geraman client does not connect to two workers.

Upvotes: 0

Views: 700

Answers (1)

wormhit
wormhit

Reputation: 3827

Not the coolest plan, but try to use database as central place where everything is controlled. It will take some resources and time for your workers but it is the cost to make it manageable.

Worker will need to check for commands (stop/restart) that are assigned to him via db. and he can also save some data into db so you can see what is happening.

Upvotes: 0

Related Questions