Пример #1
0
 public static function run()
 {
     if (!self::$_instance) {
         self::$_instance = new CoreServer();
     }
     self::$_config = CoreHelper::loadConfig('swoole', 'config');
     self::$_senderRoutes = CoreHelper::loadConfig("process_routes", "router");
     self::$_serv = new swoole_server(self::$_config["host"], self::$_config["port"]);
     self::$_serv->set(self::$_config);
     self::$_serv->on("start", [self::$_instance, "onStart"]);
     self::$_serv->on('workerStart', [self::$_instance, "onWorkerStart"]);
     self::$_serv->on('workerStop', [self::$_instance, "onWorkerStop"]);
     self::$_serv->on("connect", [self::$_instance, "onConnect"]);
     self::$_serv->on('receive', [self::$_instance, 'onReceive']);
     self::$_serv->on("close", [self::$_instance, "onClose"]);
     self::$_serv->on("task", [self::$_instance, "onTask"]);
     self::$_serv->on("finish", [self::$_instance, "onFinish"]);
     if (!empty(self::$_senderRoutes)) {
         self::createProcessSender(self::$_senderRoutes);
     }
     self::$_serv->start();
 }
Пример #2
0
        die("The application environment is not set correctly.");
}
$systemPath = "system";
$appFolder = "application";
if (defined('STDIN')) {
    chdir(dirname(__FILE__));
}
if (($_temp = realpath($systemPath)) !== FALSE) {
    $systemPath = $_temp . "/";
} else {
    $systemPath = rtrim($systemPath, "/") . "/";
}
if (!is_dir($systemPath)) {
    die("Your system folder path does not appear to be set correctly. Please open the following file and correct this: " . pathinfo(__FILE__, PATHINFO_BASENAME));
}
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
define("BASEPATH", str_replace("\\", "/", $systemPath));
if (is_dir($appFolder)) {
    if (($_temp = realpath($appFolder)) !== FALSE) {
        $appFolder = $_temp;
    }
    define("APPPATH", $appFolder . DIRECTORY_SEPARATOR);
} else {
    if (!is_dir(BASEPATH . $appFolder . DIRECTORY_SEPARATOR)) {
        die("Your application folder path does not appear to be set correctly. Please open the following file and correct this: " . SELF);
    }
    define("APPPATH", BASEPATH . $appFolder . DIRECTORY_SEPARATOR);
}
require_once BASEPATH . 'CoreServer.php';
CoreServer::run();