N
N
nepster-web2014-08-30 16:05:48
PHP
nepster-web, 2014-08-30 16:05:48

How do I set up tasks in Gearman?

Installed Gearman, put gearman-monitor in general, everything works:

Workers
Server 	IP 	Functions 	Descriptor 	Id
Gearman 	127.0.0.1 	30 	-

Gearman servers
Server 	Address 	Version
Gearman 	127.0.0.1:4730 	OK 0.33

Now, in fact, a number of questions arose that I could not deal with due to the lack of Russian docks.
How to log all queues in mysql ?
For example, there is a script that runs for several minutes. Let the same video converter or photo processor. I want to do such a thing on the site, for example, the user does some bold thing on the site and sees the message "queued, will be processed within 15 minutes", in fact, if there are a lot of such queues, I would like that instead of RAM , they were stored in the database.
How to make the worker work synchronously?
For example, there are tasks that need to be performed in a strict order. That is, until task 1 is completed, do not proceed to task 2.
Is there a worker for each task?
For example, the site has several tasks that will work through gearman. As I understand it, each task needs its own worker?
For example, the tasks are:
- user activation
- video
processing - photo processing
- photo cutting

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DnAp, 2014-09-03
@DnAp

How to log all queues in mysql ?

You need to start the Gearman daemon with parameters like this
--queue-type=MySQL \
          --mysql-host=localhost \
          --mysql-port=3306 \
          --mysql-user=gearman \
          --mysql-password=your_pw \
          --mysql-db=gearman \
          --mysql-table=gearman_queue

May not start right away as gearman can be compiled without database support.
At the end of one task, queue the second one. And in case of an error, you can set a repeated task for execution with a lower priority.
Well, for good, yes, you can even have more than one, although there are no restrictions.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question