title: Adding a new job with GearmanManager?
body: <p>I'm still new to the whole Gearman and GearmanManager cycle. I have a working server and have verified my jobs run if they're already in my queue (MySQL table) when the server starts. However, I need to be able to add a new job to the queue from PHP, and from inside of the worker if possible.</p>
  
  <p>Right now I have a job that I will be creating on the deployment of our new codebase. This will be the first job to run and it's purpose is to gather some data for reports and store it.</p>
  
  <p>This needs to be run every hour on the hour, so I want to utilize the <code>when_to_run</code> column. I've been mulling over the documentation for Gearman but I'm still confused on how I'm actually supposed to add a job to the queue.</p>
  
  <p>I've tried running:</p>
  
  <pre><code>&lt;?php
  $gm = new GearmanClient;
  $gm-&gt;addServer();
  $gm-&gt;doBackground('Metadata_Ingest_Report', '', com_create_guid());
  </code></pre>
  
  <p>On a side note, yes, I do have php-pecl-uuid installed.</p>
  
  <p>The above code just hangs and doesn't do anything. No job is added to the DB, nothing happens.</p>
  
  <p>This is due to me not fully understanding how a job gets sent, and I'm doing my best to RTM, but I'm not having any luck.</p>
  
  <p>So if there is something you can point me to, or if someone has some time to explain how I'm supposed to setup and add jobs to the MySQL queue so GearmanManager's workers pick them up that would be awesome.</p>
  
  <p><strong>Edit:</strong> So it appears that you have to call <code>$gm-&gt;addServer('127.0.0.1')</code>. According to the documentation <code>127.0.0.1</code> is supposed to be the default, but that does not appear to be the case running PHP 5.4.11. I can now get the tasks to run if I call <code>$gm-&gt;runTasks()</code> after <code>$gm-&gt;addTask()</code>. I would expect to just have to call <code>$gm-&gt;addTask()</code> and the task would be added to the DB and GearmanManager would see it and spool it up. Still digging...</p>
  
  <p>Best regards,<br>
  Andrew</p>