105 lines
3.3 KiB
PHP
Raw Normal View History

2020-03-02 16:14:20 +08:00
<?php
declare(strict_types=1);
/* 启动框架的底层驱动(原生支持 swoole、workerman 两种) */
$config['driver'] = 'workerman';
2020-03-02 16:14:20 +08:00
/* 要启动的服务器监听端口及协议 */
$config['servers'] = [
[
'host' => '0.0.0.0',
'port' => 20001,
'type' => 'websocket',
],
[
'host' => '0.0.0.0',
'port' => 20002,
'type' => 'http',
'flag' => 20002,
],
[
'host' => '0.0.0.0',
'port' => 20003,
'type' => 'http',
'flag' => 20003,
],
];
2020-03-02 16:14:20 +08:00
/* Workerman 驱动相关配置 */
$config['workerman_options'] = [
'worker_num' => 1, // 如果你只有一个 OneBot 实例连接到框架并且代码没有复杂的CPU密集计算则可把这里改为1使用全局变量
];
2020-03-02 16:14:20 +08:00
/* Swoole 驱动相关配置 */
$config['swoole_options'] = [
'coroutine_hook_flags' => SWOOLE_HOOK_ALL & (~SWOOLE_HOOK_CURL), // 协程 Hook 内容
'swoole_set' => [
'worker_num' => 1, // 如果你只有一个 OneBot 实例连接到框架并且代码没有复杂的CPU密集计算则可把这里改为1使用全局变量
'dispatch_mode' => 2, // 包分配原则,见 https://wiki.swoole.com/#/server/setting?id=dispatch_mode
'max_coroutine' => 300000, // 允许最大的协程数
'max_wait_time' => 5, // 安全退出模式下允许等待 Worker 的最长秒数
// 'task_worker_num' => 4, // 启动 TaskWorker 进程的数量(默认不启动)
// 'task_enable_coroutine' => true // TaskWorker 是否开启协程
],
'swoole_server_mode' => SWOOLE_PROCESS, // Swoole Server 启动模式,默认为 SWOOLE_PROCESS
2020-03-02 16:14:20 +08:00
];
2022-08-13 17:00:29 +08:00
/* 默认存取炸毛数据的目录相对目录时代表WORKING_DIR下的目录绝对目录按照绝对目录来 */
$config['data_dir'] = 'zm_data';
/* 框架本体运行时的一些可调配置 */
2021-06-16 00:17:30 +08:00
$config['runtime'] = [
2021-11-16 15:41:01 +08:00
'reload_delay_time' => 800,
'annotation_reader_ignore' => [ // 设置注解解析器忽略的注解名或命名空间,防止解析到不该解析的
'name' => [
'mixin',
],
'namespace' => [],
],
'timezone' => 'Asia/Shanghai',
2021-06-16 00:17:30 +08:00
];
2022-08-13 17:00:29 +08:00
/* 上下文接口类 implemented from ContextInterface */
$config['context_class'] = \ZM\Context\Context::class;
/* 允许加载插件形式 */
$config['plugin'] = [
'enable' => true,
'load_dir' => 'plugins',
];
/* 静态文件读取器 */
$config['file_server'] = [
'enable' => true,
'document_root' => $config['data_dir'] . '/public/',
'document_index' => 'index.html',
'document_code_page' => [
'404' => '404.html',
'500' => '500.html',
],
];
2022-08-27 19:51:09 +08:00
/* MySQL 和 SQLite3 数据库连接配置,框架将自动生成连接池,支持多个连接池 */
$config['database'] = [
'sqlite_db1' => [
'enable' => false,
'type' => 'sqlite',
'dbname' => 'a.db',
'pool_size' => 10,
],
'zm' => [
'enable' => false,
'type' => 'mysql',
'host' => '127.0.0.1', // 填写数据库服务器地址后才会创建数据库连接
2022-08-21 16:08:20 +08:00
'port' => 3306,
'username' => 'root',
'password' => 'ZhamaoTEST',
'dbname' => 'zm',
'charset' => 'utf8mb4',
'pool_size' => 64,
],
];
2020-04-15 10:55:10 +08:00
return $config;