1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/tiandian-easyswoole_admin

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Клонировать/Скачать
EasySwooleEvent.php 1.9 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
tiandian Отправлено 31.03.2019 12:02 e29d3c4
<?php
/**
* Created by PhpStorm.
* User: yf
* Date: 2018/5/28
* Time: 下午6:33
*/
namespace EasySwoole\EasySwoole;
use App\Process\Inotify;
use EasySwoole\EasySwoole\Swoole\EventRegister;
use EasySwoole\EasySwoole\AbstractInterface\Event;
use EasySwoole\Http\Request;
use EasySwoole\Http\Response;
use EasySwoole\Utility\File;
use EasySwoole\Component\Pool\PoolManager;
class EasySwooleEvent implements Event
{
public static function initialize()
{
// TODO: Implement initialize() method.
date_default_timezone_set('Asia/Shanghai');
//引用自定义文件配置
self::loadConf();
// 注册mysql数据库连接池
PoolManager::getInstance()->register(MysqlPool::class, Config::getInstance()->getConf('MYSQL.POOL_MAX_NUM'));
}
/**
* 引用自定义配置文件
* @throws \Exception
*/
public static function loadConf()
{
$files = File::scanDirectory(EASYSWOOLE_ROOT . '/App/Config');
if (is_array($files)) {
foreach ($files['files'] as $file) {
$fileNameArr = explode('.', $file);
$fileSuffix = end($fileNameArr);
if ($fileSuffix == 'php') {
Config::getInstance()->loadFile($file);
} elseif ($fileSuffix == 'env') {
Config::getInstance()->loadEnv($file);
}
}
}
}
public static function mainServerCreate(EventRegister $register)
{
// 开启热重启进程
ServerManager::getInstance()->getSwooleServer()->addProcess((new Inotify('autoReload', ['disableInotify' => false]))->getProcess());
}
public static function onRequest(Request $request, Response $response): bool
{
// TODO: Implement onRequest() method.
return true;
}
public static function afterRequest(Request $request, Response $response): void
{
// TODO: Implement afterAction() method.
}
}

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/tiandian-easyswoole_admin.git
git@api.gitlife.ru:oschina-mirror/tiandian-easyswoole_admin.git
oschina-mirror
tiandian-easyswoole_admin
tiandian-easyswoole_admin
master