Ejemplo n.º 1
0
 public function daemonize($id, $invocation)
 {
     $worker = new Definition('Nfx\\AsyncBundle\\Daemon\\Daemon');
     $worker->addMethodCall('bind', array($invocation));
     $this->container->setDefinition($id, $worker);
     $executablePath = '/opt/local/bin/php';
     $consoleTool = sprintf('%s/console', $this->appFolder);
     $command = sprintf('%s %s async:invoke %s start', $executablePath, $consoleTool, $id);
     $daemon = new Daemon();
     $daemon->setCommand($command);
     $daemon->setName($id);
     $daemon->setNumprocs(2);
     $daemon->setGroup('dev');
     $this->daemons[$id] = $daemon;
     // TODO: probably only in DEV mode
     //$daemon->attach($this->container->get('org.supervisord'));
     //$daemon->start();
 }
Ejemplo n.º 2
0
    public function testGetsProcessInfo()
    {
        $adapter = new Adapter();
        $value = <<<RPC
<?xml version='1.0'?>
<methodResponse>
<params>
<param>
<value><struct>
<member>
<name>description</name>
<value><string></string></value>
</member>
<member>
<name>pid</name>
<value><int>19742</int></value>
</member>
<member>
<name>stderr_logfile</name>
<value><string>/var/folders/sJ/sJ+C2nnMHWSznunco0jPlU+++TI/-Tmp-/tacker-0-stderr---supervisor-pZugUW.log</string></value>
</member>
<member>
<name>stop</name>
<value><int>0</int></value>
</member>
<member>
<name>logfile</name>
<value><string>/var/folders/sJ/sJ+C2nnMHWSznunco0jPlU+++TI/-Tmp-/tacker-0-stdout---supervisor-oGAjra.log</string></value>
</member>
<member>
<name>exitstatus</name>
<value><int>0</int></value>
</member>
<member>
<name>spawnerr</name>
<value><string></string></value>
</member>
<member>
<name>now</name>
<value><int>1339280452</int></value>
</member>
<member>
<name>group</name>
<value><string>dev</string></value>
</member>
<member>
<name>name</name>
<value><string>tacker-0</string></value>
</member>
<member>
<name>statename</name>
<value><string>STARTING</string></value>
</member>
<member>
<name>start</name>
<value><int>1339280452</int></value>
</member>
<member>
<name>state</name>
<value><int>10</int></value>
</member>
<member>
<name>stdout_logfile</name>
<value><string>/var/folders/sJ/sJ+C2nnMHWSznunco0jPlU+++TI/-Tmp-/tacker-0-stdout---supervisor-oGAjra.log</string></value>
</member>
</struct></value>
</param>
</params>
</methodResponse>
RPC;
        $expected = array('description' => '', 'pid' => 19742, 'stderr_logfile' => '/var/folders/sJ/sJ+C2nnMHWSznunco0jPlU+++TI/-Tmp-/tacker-0-stderr---supervisor-pZugUW.log', 'stop' => 0, 'logfile' => '/var/folders/sJ/sJ+C2nnMHWSznunco0jPlU+++TI/-Tmp-/tacker-0-stdout---supervisor-oGAjra.log', 'exitstatus' => 0, 'spawnerr' => '', 'now' => 1339280452, 'group' => 'dev', 'name' => 'tacker-0', 'statename' => 'STARTING', 'start' => 1339280452, 'state' => 10, 'stdout_logfile' => '/var/folders/sJ/sJ+C2nnMHWSznunco0jPlU+++TI/-Tmp-/tacker-0-stdout---supervisor-oGAjra.log');
        $adapter->setHttpClient($this->mockBrowser($value));
        $timer = new Daemon($adapter);
        $timer->setName('tacker');
        $timer->setGroup('dev');
        $timer->setNumprocs(2);
        $timer->setCommand('/usr/bin/php /Users/nfx/Projects/Playground/async/src/Nfx/AsyncBundle/t.php');
        //$timer->attach();
        $status = $adapter->getProcessInfo('dev', 'tacker', 0);
        $this->assertEquals($expected, $status, var_export($status, true));
    }