Quantcast

Gearman worker as Console command

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Gearman worker as Console command

baur79
Hi,

is it possable to use Console/cake some_command as Gearman Worker
please suggest some idea?

thanks in advance

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Gearman worker as Console command

Dr. Tarique Sani
Yes it is possible to use a shell as a worker. Just create the shell
start and forget. Also do not try to do a lot in the worker - use your
models for that

HTH
Tarique



On Mon, Jun 25, 2012 at 9:47 PM, baur79 <[hidden email]> wrote:

> Hi,
>
> is it possable to use Console/cake some_command as Gearman Worker
> please suggest some idea?
>
> thanks in advance
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> [hidden email] For more options, visit this group at
> http://groups.google.com/group/cake-php



--
=============================================================
PHP for E-Biz: http://sanisoft.com
=============================================================

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Gearman worker as Console command

baur79
but how to run the function by 
$worker->addFunction("func", "func_my");


On Tuesday, June 26, 2012 6:11:56 PM UTC+6, Dr. Tarique Sani wrote:
Yes it is possible to use a shell as a worker. Just create the shell
start and forget. Also do not try to do a lot in the worker - use your
models for that

HTH
Tarique



On Mon, Jun 25, 2012 at 9:47 PM, baur79 <[hidden email]> wrote:

> Hi,
>
> is it possable to use Console/cake some_command as Gearman Worker
> please suggest some idea?
>
> thanks in advance
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> [hidden email] For more options, visit this group at
> http://groups.google.com/group/cake-php



--
=============================================================
PHP for E-Biz: http://sanisoft.com
=============================================================

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Gearman worker as Console command

Dr. Tarique Sani
On Tue, Jun 26, 2012 at 9:13 PM, baur79 <[hidden email]> wrote:
> but how to run the function by
> $worker->addFunction("func", "func_my");

Something like

$this->worker = new gearmanworker()

then

$this->worker->addFunction("func", "func_my");

Of course presuming that somewhere you have already added the servers

Tarique

--
=============================================================
PHP for E-Biz: http://sanisoft.com
=============================================================

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Gearman worker as Console command

baur79
i'm about how to run function in 
class GrmShell extend  AppShell

public function main() {
 $this->worker = new gearmanworker() 
 $this->worker->addFunction("func", "func_my");  
}

public function func_my() {
 // run logic


On Wednesday, June 27, 2012 10:28:04 AM UTC+6, Dr. Tarique Sani wrote:
On Tue, Jun 26, 2012 at 9:13 PM, baur79 <[hidden email]> wrote:
> but how to run the function by
> $worker->addFunction("func", "func_my");

Something like

$this->worker = new gearmanworker()

then

$this->worker->addFunction("func", "func_my");

Of course presuming that somewhere you have already added the servers

Tarique

--
=============================================================
PHP for E-Biz: http://sanisoft.com
=============================================================

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Gearman worker as Console command

Dr. Tarique Sani
On Wed, Jun 27, 2012 at 1:05 PM, baur79 <[hidden email]> wrote:

> i'm about how to run function in
> class GrmShell extend  AppShell
>
> public function main() {
>  $this->worker = new gearmanworker()
>  $this->worker->addFunction("func", "func_my");
> }
>
> public function func_my() {
>  // run logic
> }
>

Ummm.... I have lost you here... You have to start the worker and let it run.

When ever a worker receives a job it will run.

Have you tried running gearman examples without cakePHP?

Tarique

--
=============================================================
PHP for E-Biz: http://sanisoft.com
=============================================================

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Gearman worker as Console command

baur79
gearman working good outside of cakephp as plan PHP
but my need is to use in cakephp shell, so to use ORM of cakephp models

On Wednesday, June 27, 2012 3:22:08 PM UTC+6, Dr. Tarique Sani wrote:
On Wed, Jun 27, 2012 at 1:05 PM, baur79 <[hidden email]> wrote:

> i'm about how to run function in
> class GrmShell extend  AppShell
>
> public function main() {
>  $this->worker = new gearmanworker()
>  $this->worker->addFunction("func", "func_my");
> }
>
> public function func_my() {
>  // run logic
> }
>

Ummm.... I have lost you here... You have to start the worker and let it run.

When ever a worker receives a job it will run.

Have you tried running gearman examples without cakePHP?

Tarique

--

=============================================================
PHP for E-Biz: http://sanisoft.com
=============================================================


On Wednesday, June 27, 2012 3:22:08 PM UTC+6, Dr. Tarique Sani wrote:
On Wed, Jun 27, 2012 at 1:05 PM, baur79 <[hidden email]> wrote:

> i'm about how to run function in
> class GrmShell extend  AppShell
>
> public function main() {
>  $this->worker = new gearmanworker()
>  $this->worker->addFunction("func", "func_my");
> }
>
> public function func_my() {
>  // run logic
> }
>

Ummm.... I have lost you here... You have to start the worker and let it run.

When ever a worker receives a job it will run.

Have you tried running gearman examples without cakePHP?

Tarique

--

=============================================================
PHP for E-Biz: http://sanisoft.com
=============================================================


On Wednesday, June 27, 2012 3:22:08 PM UTC+6, Dr. Tarique Sani wrote:
On Wed, Jun 27, 2012 at 1:05 PM, baur79 <[hidden email]> wrote:

> i'm about how to run function in
> class GrmShell extend  AppShell
>
> public function main() {
>  $this->worker = new gearmanworker()
>  $this->worker->addFunction("func", "func_my");
> }
>
> public function func_my() {
>  // run logic
> }
>

Ummm.... I have lost you here... You have to start the worker and let it run.

When ever a worker receives a job it will run.

Have you tried running gearman examples without cakePHP?

Tarique

--

=============================================================
PHP for E-Biz: http://sanisoft.com
=============================================================

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Gearman worker as Console command

Dr. Tarique Sani
public $uses = array('User');

Will give you the $this->User in your shell - what is the problem?

Tarique

On Wed, Jun 27, 2012 at 10:56 PM, baur79 <[hidden email]> wrote:

> gearman working good outside of cakephp as plan PHP
> but my need is to use in cakephp shell, so to use ORM of cakephp models
>
>
> On Wednesday, June 27, 2012 3:22:08 PM UTC+6, Dr. Tarique Sani wrote:
>>
>> On Wed, Jun 27, 2012 at 1:05 PM, baur79 <[hidden email]> wrote:
>> > i'm about how to run function in
>> > class GrmShell extend  AppShell
>> >
>> > public function main() {
>> >  $this->worker = new gearmanworker()
>> >  $this->worker->addFunction("func", "func_my");
>> > }
>> >
>> > public function func_my() {
>> >  // run logic
>> > }
>> >
>>
>> Ummm.... I have lost you here... You have to start the worker and let it
>> run.
>>
>> When ever a worker receives a job it will run.
>>
>> Have you tried running gearman examples without cakePHP?
>>
>> Tarique
>>
>> --
>> =============================================================
>> PHP for E-Biz: http://sanisoft.com
>> =============================================================
>
>
> On Wednesday, June 27, 2012 3:22:08 PM UTC+6, Dr. Tarique Sani wrote:
>>
>> On Wed, Jun 27, 2012 at 1:05 PM, baur79 <[hidden email]> wrote:
>> > i'm about how to run function in
>> > class GrmShell extend  AppShell
>> >
>> > public function main() {
>> >  $this->worker = new gearmanworker()
>> >  $this->worker->addFunction("func", "func_my");
>> > }
>> >
>> > public function func_my() {
>> >  // run logic
>> > }
>> >
>>
>> Ummm.... I have lost you here... You have to start the worker and let it
>> run.
>>
>> When ever a worker receives a job it will run.
>>
>> Have you tried running gearman examples without cakePHP?
>>
>> Tarique
>>
>> --
>> =============================================================
>> PHP for E-Biz: http://sanisoft.com
>> =============================================================
>
>
> On Wednesday, June 27, 2012 3:22:08 PM UTC+6, Dr. Tarique Sani wrote:
>>
>> On Wed, Jun 27, 2012 at 1:05 PM, baur79 <[hidden email]> wrote:
>> > i'm about how to run function in
>> > class GrmShell extend  AppShell
>> >
>> > public function main() {
>> >  $this->worker = new gearmanworker()
>> >  $this->worker->addFunction("func", "func_my");
>> > }
>> >
>> > public function func_my() {
>> >  // run logic
>> > }
>> >
>>
>> Ummm.... I have lost you here... You have to start the worker and let it
>> run.
>>
>> When ever a worker receives a job it will run.
>>
>> Have you tried running gearman examples without cakePHP?
>>
>> Tarique
>>
>> --
>> =============================================================
>> PHP for E-Biz: http://sanisoft.com
>> =============================================================
>
> --
> Our newest site for the community: CakePHP Video Tutorials
> http://tv.cakephp.org
> Check out the new CakePHP Questions site http://ask.cakephp.org and help
> others with their CakePHP related questions.
>
>
> To unsubscribe from this group, send email to
> [hidden email] For more options, visit this group at
> http://groups.google.com/group/cake-php



--
=============================================================
PHP for E-Biz: http://sanisoft.com
=============================================================

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Gearman worker as Console command

Dr. Tarique Sani
Tired of all the back and forth in this thread my colleague Amit wrote
this blog post

http://www.sanisoft.com/blog/2012/06/28/cakephp-do-dlrow-olleh-using-gearman/

That should solve most of your problems :-)

Tarique

On Thu, Jun 28, 2012 at 8:56 AM, Dr. Tarique Sani <[hidden email]> wrote:

> public $uses = array('User');
>
> Will give you the $this->User in your shell - what is the problem?
>
> Tarique
>
> On Wed, Jun 27, 2012 at 10:56 PM, baur79 <[hidden email]> wrote:
>> gearman working good outside of cakephp as plan PHP
>> but my need is to use in cakephp shell, so to use ORM of cakephp models
>>
>>
>> On Wednesday, June 27, 2012 3:22:08 PM UTC+6, Dr. Tarique Sani wrote:
>>>
>>> On Wed, Jun 27, 2012 at 1:05 PM, baur79 <[hidden email]> wrote:
>>> > i'm about how to run function in
>>> > class GrmShell extend  AppShell
>>> >
>>> > public function main() {
>>> >  $this->worker = new gearmanworker()
>>> >  $this->worker->addFunction("func", "func_my");
>>> > }
>>> >
>>> > public function func_my() {
>>> >  // run logic
>>> > }
>>> >
>>>
>>> Ummm.... I have lost you here... You have to start the worker and let it
>>> run.
>>>
>>> When ever a worker receives a job it will run.
>>>
>>> Have you tried running gearman examples without cakePHP?
>>>
>>> Tarique
>>>
>>> --
>>> =============================================================
>>> PHP for E-Biz: http://sanisoft.com
>>> =============================================================
>>
>>
>> On Wednesday, June 27, 2012 3:22:08 PM UTC+6, Dr. Tarique Sani wrote:
>>>
>>> On Wed, Jun 27, 2012 at 1:05 PM, baur79 <[hidden email]> wrote:
>>> > i'm about how to run function in
>>> > class GrmShell extend  AppShell
>>> >
>>> > public function main() {
>>> >  $this->worker = new gearmanworker()
>>> >  $this->worker->addFunction("func", "func_my");
>>> > }
>>> >
>>> > public function func_my() {
>>> >  // run logic
>>> > }
>>> >
>>>
>>> Ummm.... I have lost you here... You have to start the worker and let it
>>> run.
>>>
>>> When ever a worker receives a job it will run.
>>>
>>> Have you tried running gearman examples without cakePHP?
>>>
>>> Tarique
>>>
>>> --
>>> =============================================================
>>> PHP for E-Biz: http://sanisoft.com
>>> =============================================================
>>
>>
>> On Wednesday, June 27, 2012 3:22:08 PM UTC+6, Dr. Tarique Sani wrote:
>>>
>>> On Wed, Jun 27, 2012 at 1:05 PM, baur79 <[hidden email]> wrote:
>>> > i'm about how to run function in
>>> > class GrmShell extend  AppShell
>>> >
>>> > public function main() {
>>> >  $this->worker = new gearmanworker()
>>> >  $this->worker->addFunction("func", "func_my");
>>> > }
>>> >
>>> > public function func_my() {
>>> >  // run logic
>>> > }
>>> >
>>>
>>> Ummm.... I have lost you here... You have to start the worker and let it
>>> run.
>>>
>>> When ever a worker receives a job it will run.
>>>
>>> Have you tried running gearman examples without cakePHP?
>>>
>>> Tarique
>>>
>>> --
>>> =============================================================
>>> PHP for E-Biz: http://sanisoft.com
>>> =============================================================
>>
>> --
>> Our newest site for the community: CakePHP Video Tutorials
>> http://tv.cakephp.org
>> Check out the new CakePHP Questions site http://ask.cakephp.org and help
>> others with their CakePHP related questions.
>>
>>
>> To unsubscribe from this group, send email to
>> [hidden email] For more options, visit this group at
>> http://groups.google.com/group/cake-php
>
>
>
> --
> =============================================================
> PHP for E-Biz: http://sanisoft.com
> =============================================================



--
=============================================================
PHP for E-Biz: http://sanisoft.com
=============================================================

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Gearman worker as Console command

AD7six
In reply to this post by baur79


On Monday, 25 June 2012 18:17:56 UTC+2, baur79 wrote:
Hi,

is it possable to use Console/cake some_command as Gearman Worker
please suggest some idea?

thanks in advance

Just follow the gearman docs to setup a worker if you want a dedicated gearman worker cli, The linked example on sanisoft is pretty easy to follow if you want a worker to do one thing.

You can also use gearman in worker mode to run arbitrary cake commands:

    cd /an/app/install
    nohup gearman -w -f console -- xargs -0 -i -t sh -c "Console/cake {}" & 

That needs only one daemon to run any console command. Then, anywhere in your code:

    $g = new \GearmanClient();
    $g->addServer();
    $g->doBackground('console', 'bake controller examples'); // requests `Console/cake bake controller examples` to be ran in the background

That can give great flexibility in what things you can send to the background.

AD

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
[hidden email] For more options, visit this group at http://groups.google.com/group/cake-php
Loading...