Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question on documentation #2

Closed
ejsmont-artur opened this issue Mar 22, 2013 · 2 comments
Closed

Question on documentation #2

ejsmont-artur opened this issue Mar 22, 2013 · 2 comments

Comments

@ejsmont-artur
Copy link

Hi there Mateusz, I liked your bundle i am not sure though what is the best way to run the worker processes as i would prefer them to be deamons not cron based if that is possible. So if i had a worker sending emails i want it to keep going and restarting itself from time to time or even for each message just to keep processes clean and small.

Is there a recommended way to do it with your bundle?

Keep up the good work :)

ps. pozdrowienia z Sydney.

Art

@mcharytoniuk
Copy link
Contributor

@ejsmont-artur

Sorry for a delayed reply.

I would personally stay with cron and use script like this one I have created recently:

https://github.com/laelaps/symfony-gearman-bundle/blob/master/Tool/php-watcher.sh

If you run this script every minute with cron (I think this is a reasonable time) it will:

  • check if there is a new worker matching given pattern and if so - run it
  • check if every worker is running and if not - run it
  • check if source code of worker changed after running it (!) and if so - restart this one particular worker

Sample usage is:

$ php-watcher.sh "/full/path/to/your/workers/*php" "/full/path/to/your/log/directory" "php /full/path/to/app/console gearman:worker:run"

This way you can be sure that even in an emergency situation (for example - long running worker crashed after exceeding memory limit), not a single worker will be down for longer than one minute.

This way you can safely order script to kill itself with exit or die anytime and be sure that it will return in a minute.

@ejsmont-artur
Copy link
Author

Thanks man, in the mean time i found supervisors, its quite awesome so ill go with it.

http://supervisord.org/

Cheers

Art

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants