0

If you have a Gearman worker server and you have a Worker.php file, i.e.

    <?php
      $worker = new GearmanWorker();
      $worker->addServer('...');
      $worker->addFunction("customFunction", "my_custom_function");

      while ($worker->work());

      function my_custom_function($job)
      {
         return doStuff($job->workload());
      }
     ?>

Where does this file go? Does it go on the actual worker server and every worker server that you want to handle this type of job or what? Simple question. I just don't know the answer.

SonOfSeuss
  • 400
  • 5
  • 18

1 Answers1

1

Yes. The worker machine becomes a worker machine by running this script. To run this script you need to put it on the machine and execute it, likely from the command line using php Worker.php.

deceze
  • 510,633
  • 85
  • 743
  • 889
  • Great. Thanks. Sorry it was so simple but my text didn't explain that small (but critical) point. – SonOfSeuss Oct 02 '12 at 23:38
  • Note that the worker and the server can be the same physical machine and that you can run as many instances of the worker as you want on the same machine. – deceze Oct 02 '12 at 23:42
  • Hey. Can you use Gearman and APC together? Preprocess the PHP using APC and then use Gearman for the job calls? – SonOfSeuss Oct 03 '12 at 00:00
  • 1
    Maybe. It's not really all that useful for long-running scripts like Gearman workers though. It's a lot more useful for often-invoked short-running scripts in a web server context. – deceze Oct 03 '12 at 00:11