Ejemplo n.º 1
0
 /**
  * 开启http服务 web api
  * @param $opt
  */
 public static function params_http($opt)
 {
     if (!isset($opt["http"])) {
         return false;
     }
     if (isset($opt["host"]) && $opt["host"]) {
         self::$host = $opt["host"];
     }
     if (isset($opt["port"]) && $opt["port"]) {
         self::$port = $opt["port"];
     }
     $process = new swoole_process(array(new Main(), "http_run"));
     $process->start();
     self::$http_server = $process;
     swoole_event_add($process->pipe, function ($pipe) use($process) {
         $manager = new Manager();
         $recv = $process->read();
         $recv = explode("#@#", $recv);
         $function = $recv[0] . "_cron";
         $process->write(json_encode($manager->{$function}(json_decode($recv[1], true))));
     });
     return true;
 }
Ejemplo n.º 2
0
 /**
  * 开启http服务 web api
  * @param $opt
  */
 public static function params_http($opt)
 {
     if (!isset($opt["http"])) {
         return false;
     }
     if (isset($opt["host"]) && $opt["host"]) {
         self::$host = $opt["host"];
     }
     if (isset($opt["port"]) && $opt["port"]) {
         self::$port = $opt["port"];
     }
     //        swoole_event_add($process->pipe, function ($pipe) use ($process) {
     //            $manager = new Manager();
     //            $recv = $process->read();
     //            $recv = explode("#@#", $recv);
     //            $function = $recv[0] . "_cron";
     //            $process->write(json_encode($manager->$function(json_decode($recv[1], true))));
     //        });
     return true;
 }