Ejemplo n.º 1
0
 public function restart()
 {
     $length = strlen($this->getName());
     foreach ($this->supervisor->getAllProcessInfo() as $i) {
         if ($this->getName() == substr($i['name'], 0, $length)) {
             if ('STOPPED' == $i['statename']) {
                 $this->supervisor->startProcess($this->getGroup(), $i['name']);
                 sleep(1);
                 // sleep while process starts
             }
         }
     }
     return true;
 }
Ejemplo n.º 2
0
    public function testGetsAllProcessInfo()
    {
        $adapter = new Adapter();
        $value = <<<RPC
<?xml version='1.0'?>
<methodResponse>
<params>
<param>
<value><array><data>
<value><struct>
<member>
<name>description</name>
<value><string>Exited too quickly (process log may have details)</string></value>
</member>
<member>
<name>pid</name>
<value><int>0</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>1339280458</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>Exited too quickly (process log may have details)</string></value>
</member>
<member>
<name>now</name>
<value><int>1339280697</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>FATAL</string></value>
</member>
<member>
<name>start</name>
<value><int>1339280458</int></value>
</member>
<member>
<name>state</name>
<value><int>200</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>
<value><struct>
<member>
<name>description</name>
<value><string>Exited too quickly (process log may have details)</string></value>
</member>
<member>
<name>pid</name>
<value><int>0</int></value>
</member>
<member>
<name>stderr_logfile</name>
<value><string>/var/folders/sJ/sJ+C2nnMHWSznunco0jPlU+++TI/-Tmp-/tacker-1-stderr---supervisor-GbR3mv.log</string></value>
</member>
<member>
<name>stop</name>
<value><int>1339280458</int></value>
</member>
<member>
<name>logfile</name>
<value><string>/var/folders/sJ/sJ+C2nnMHWSznunco0jPlU+++TI/-Tmp-/tacker-1-stdout---supervisor-fWtS53.log</string></value>
</member>
<member>
<name>exitstatus</name>
<value><int>0</int></value>
</member>
<member>
<name>spawnerr</name>
<value><string>Exited too quickly (process log may have details)</string></value>
</member>
<member>
<name>now</name>
<value><int>1339280697</int></value>
</member>
<member>
<name>group</name>
<value><string>dev</string></value>
</member>
<member>
<name>name</name>
<value><string>tacker-1</string></value>
</member>
<member>
<name>statename</name>
<value><string>FATAL</string></value>
</member>
<member>
<name>start</name>
<value><int>1339280458</int></value>
</member>
<member>
<name>state</name>
<value><int>200</int></value>
</member>
<member>
<name>stdout_logfile</name>
<value><string>/var/folders/sJ/sJ+C2nnMHWSznunco0jPlU+++TI/-Tmp-/tacker-1-stdout---supervisor-fWtS53.log</string></value>
</member>
</struct></value>
<value><struct>
<member>
<name>description</name>
<value><string>Jun 09 11:34 PM</string></value>
</member>
<member>
<name>pid</name>
<value><int>0</int></value>
</member>
<member>
<name>stderr_logfile</name>
<value><string>/var/folders/sJ/sJ+C2nnMHWSznunco0jPlU+++TI/-Tmp-/ticker-0-stderr---supervisor-Txnho9.log</string></value>
</member>
<member>
<name>stop</name>
<value><int>1339274053</int></value>
</member>
<member>
<name>logfile</name>
<value><string>/var/folders/sJ/sJ+C2nnMHWSznunco0jPlU+++TI/-Tmp-/ticker-0-stdout---supervisor-RIIZQM.log</string></value>
</member>
<member>
<name>exitstatus</name>
<value><int>-1</int></value>
</member>
<member>
<name>spawnerr</name>
<value><string></string></value>
</member>
<member>
<name>now</name>
<value><int>1339280697</int></value>
</member>
<member>
<name>group</name>
<value><string>dev</string></value>
</member>
<member>
<name>name</name>
<value><string>ticker-0</string></value>
</member>
<member>
<name>statename</name>
<value><string>STOPPED</string></value>
</member>
<member>
<name>start</name>
<value><int>1339274049</int></value>
</member>
<member>
<name>state</name>
<value><int>0</int></value>
</member>
<member>
<name>stdout_logfile</name>
<value><string>/var/folders/sJ/sJ+C2nnMHWSznunco0jPlU+++TI/-Tmp-/ticker-0-stdout---supervisor-RIIZQM.log</string></value>
</member>
</struct></value>
<value><struct>
<member>
<name>description</name>
<value><string>Jun 09 11:34 PM</string></value>
</member>
<member>
<name>pid</name>
<value><int>0</int></value>
</member>
<member>
<name>stderr_logfile</name>
<value><string>/var/folders/sJ/sJ+C2nnMHWSznunco0jPlU+++TI/-Tmp-/ticker-1-stderr---supervisor-mHbOOH.log</string></value>
</member>
<member>
<name>stop</name>
<value><int>1339274055</int></value>
</member>
<member>
<name>logfile</name>
<value><string>/var/folders/sJ/sJ+C2nnMHWSznunco0jPlU+++TI/-Tmp-/ticker-1-stdout---supervisor-KIjL6o.log</string></value>
</member>
<member>
<name>exitstatus</name>
<value><int>-1</int></value>
</member>
<member>
<name>spawnerr</name>
<value><string></string></value>
</member>
<member>
<name>now</name>
<value><int>1339280697</int></value>
</member>
<member>
<name>group</name>
<value><string>dev</string></value>
</member>
<member>
<name>name</name>
<value><string>ticker-1</string></value>
</member>
<member>
<name>statename</name>
<value><string>STOPPED</string></value>
</member>
<member>
<name>start</name>
<value><int>1339274051</int></value>
</member>
<member>
<name>state</name>
<value><int>0</int></value>
</member>
<member>
<name>stdout_logfile</name>
<value><string>/var/folders/sJ/sJ+C2nnMHWSznunco0jPlU+++TI/-Tmp-/ticker-1-stdout---supervisor-KIjL6o.log</string></value>
</member>
</struct></value>
</data></array></value>
</param>
</params>
</methodResponse>
RPC;
        $expected = array(0 => array('description' => 'Exited too quickly (process log may have details)', 'pid' => 0, 'stderr_logfile' => '/var/folders/sJ/sJ+C2nnMHWSznunco0jPlU+++TI/-Tmp-/tacker-0-stderr---supervisor-pZugUW.log', 'stop' => 1339280458, 'logfile' => '/var/folders/sJ/sJ+C2nnMHWSznunco0jPlU+++TI/-Tmp-/tacker-0-stdout---supervisor-oGAjra.log', 'exitstatus' => 0, 'spawnerr' => 'Exited too quickly (process log may have details)', 'now' => 1339280697, 'group' => 'dev', 'name' => 'tacker-0', 'statename' => 'FATAL', 'start' => 1339280458, 'state' => 200, 'stdout_logfile' => '/var/folders/sJ/sJ+C2nnMHWSznunco0jPlU+++TI/-Tmp-/tacker-0-stdout---supervisor-oGAjra.log'), 1 => array('description' => 'Exited too quickly (process log may have details)', 'pid' => 0, 'stderr_logfile' => '/var/folders/sJ/sJ+C2nnMHWSznunco0jPlU+++TI/-Tmp-/tacker-1-stderr---supervisor-GbR3mv.log', 'stop' => 1339280458, 'logfile' => '/var/folders/sJ/sJ+C2nnMHWSznunco0jPlU+++TI/-Tmp-/tacker-1-stdout---supervisor-fWtS53.log', 'exitstatus' => 0, 'spawnerr' => 'Exited too quickly (process log may have details)', 'now' => 1339280697, 'group' => 'dev', 'name' => 'tacker-1', 'statename' => 'FATAL', 'start' => 1339280458, 'state' => 200, 'stdout_logfile' => '/var/folders/sJ/sJ+C2nnMHWSznunco0jPlU+++TI/-Tmp-/tacker-1-stdout---supervisor-fWtS53.log'), 2 => array('description' => 'Jun 09 11:34 PM', 'pid' => 0, 'stderr_logfile' => '/var/folders/sJ/sJ+C2nnMHWSznunco0jPlU+++TI/-Tmp-/ticker-0-stderr---supervisor-Txnho9.log', 'stop' => 1339274053, 'logfile' => '/var/folders/sJ/sJ+C2nnMHWSznunco0jPlU+++TI/-Tmp-/ticker-0-stdout---supervisor-RIIZQM.log', 'exitstatus' => -1, 'spawnerr' => '', 'now' => 1339280697, 'group' => 'dev', 'name' => 'ticker-0', 'statename' => 'STOPPED', 'start' => 1339274049, 'state' => 0, 'stdout_logfile' => '/var/folders/sJ/sJ+C2nnMHWSznunco0jPlU+++TI/-Tmp-/ticker-0-stdout---supervisor-RIIZQM.log'), 3 => array('description' => 'Jun 09 11:34 PM', 'pid' => 0, 'stderr_logfile' => '/var/folders/sJ/sJ+C2nnMHWSznunco0jPlU+++TI/-Tmp-/ticker-1-stderr---supervisor-mHbOOH.log', 'stop' => 1339274055, 'logfile' => '/var/folders/sJ/sJ+C2nnMHWSznunco0jPlU+++TI/-Tmp-/ticker-1-stdout---supervisor-KIjL6o.log', 'exitstatus' => -1, 'spawnerr' => '', 'now' => 1339280697, 'group' => 'dev', 'name' => 'ticker-1', 'statename' => 'STOPPED', 'start' => 1339274051, 'state' => 0, 'stdout_logfile' => '/var/folders/sJ/sJ+C2nnMHWSznunco0jPlU+++TI/-Tmp-/ticker-1-stdout---supervisor-KIjL6o.log'));
        //$adapter->setHttpClient(new \Buzz\Browser());
        $adapter->setHttpClient($this->mockBrowser($value));
        $status = $adapter->getAllProcessInfo();
        $this->assertEquals($expected, $status, var_export($status, true));
    }