示例#1
0
    {
        $this->flags = ServiceInstance::SVC_RESTART + ServiceInstance::SVC_NO_DELAY;
    }
    function servicemain()
    {
        for ($s = 0; $s < 5; $s++) {
            usleep(100000);
            echo ".";
        }
    }
    function servicehalt()
    {
        echo "X\n";
    }
}
SvcMan::addServiceInstance(new TestService());
class TestClass
{
    public function __construct($name)
    {
        $this->name = ucwords($name);
    }
    public function hello()
    {
        echo "Hello {$this->name}!\n";
    }
}
class HelloFactory implements IObjectManagerInterface
{
    public function omiGetNodeList($path)
    {
示例#2
0
<?php

require_once __DIR__ . "/../../share/include/cherryphp";
use Cherry\Core\ServiceManager as SvcMan;
use Cherry\Core\ServiceInstance;
SvcMan::register();
class TestService extends ServiceInstance
{
    public $serviceid = "info.noccylabs.testservice";
    protected $flags = ServiceInstance::SVC_RESTART;
    function servicemain()
    {
        for ($s = 0; $s < 5; $s++) {
            usleep(100000);
        }
    }
    function onShutdown()
    {
    }
}
SvcMan::addServiceInstance(new TestService("/tmp/testservice.pid"));
App::run(new \Cherry\Cli\ServiceController("local:/services/info.noccylabs.testservice#0", __DIR__), __DIR__);