2020-03-02 16:14:20 +08:00
|
|
|
|
<?php
|
2020-10-03 23:00:18 +08:00
|
|
|
|
/** @noinspection PhpFullyQualifiedNameUsageInspection */
|
|
|
|
|
|
/** @noinspection PhpComposerExtensionStubsInspection */
|
2020-03-02 16:14:20 +08:00
|
|
|
|
global $config;
|
|
|
|
|
|
|
|
|
|
|
|
/** bind host */
|
|
|
|
|
|
$config['host'] = '0.0.0.0';
|
|
|
|
|
|
|
|
|
|
|
|
/** bind port */
|
|
|
|
|
|
$config['port'] = 20001;
|
|
|
|
|
|
|
2020-03-12 18:31:35 +08:00
|
|
|
|
/** 框架开到公网或外部的HTTP访问链接,通过 DataProvider::getFrameworkLink() 获取 */
|
2020-07-27 09:52:52 +08:00
|
|
|
|
$config['http_reverse_link'] = "http://127.0.0.1:" . $config['port'];
|
2020-03-12 18:31:35 +08:00
|
|
|
|
|
2020-05-23 17:23:29 +08:00
|
|
|
|
/** 框架是否启动debug模式 */
|
|
|
|
|
|
$config['debug_mode'] = false;
|
|
|
|
|
|
|
2020-03-02 16:14:20 +08:00
|
|
|
|
/** 存放框架内文件数据的目录 */
|
2020-07-27 09:52:52 +08:00
|
|
|
|
$config['zm_data'] = realpath(__DIR__ . "/../") . '/zm_data/';
|
2020-03-02 16:14:20 +08:00
|
|
|
|
|
|
|
|
|
|
/** 存放各个模块配置文件的目录 */
|
2020-07-27 09:52:52 +08:00
|
|
|
|
$config['config_dir'] = $config['zm_data'] . 'config/';
|
2020-03-02 16:14:20 +08:00
|
|
|
|
|
|
|
|
|
|
/** 存放崩溃和运行日志的目录 */
|
2020-07-27 09:52:52 +08:00
|
|
|
|
$config['crash_dir'] = $config['zm_data'] . 'crash/';
|
2020-03-02 16:14:20 +08:00
|
|
|
|
|
|
|
|
|
|
/** 对应swoole的server->set参数 */
|
|
|
|
|
|
$config['swoole'] = [
|
2020-07-27 09:52:52 +08:00
|
|
|
|
'log_file' => $config['crash_dir'] . 'swoole_error.log',
|
2020-11-08 19:40:16 +08:00
|
|
|
|
'worker_num' => swoole_cpu_num(), //如果你只有一个 OneBot 实例连接到框架并且代码没有复杂的CPU密集计算,则可把这里改为1使用全局变量
|
2020-11-04 18:43:50 +08:00
|
|
|
|
'dispatch_mode' => 2, //包分配原则,见 https://wiki.swoole.com/#/server/setting?id=dispatch_mode
|
2020-11-03 21:02:24 +08:00
|
|
|
|
'max_coroutine' => 300000,
|
2020-09-29 15:07:43 +08:00
|
|
|
|
//'task_worker_num' => 4,
|
2020-07-11 15:53:30 +08:00
|
|
|
|
//'task_enable_coroutine' => true
|
2020-03-02 16:14:20 +08:00
|
|
|
|
];
|
|
|
|
|
|
|
2020-09-29 15:07:43 +08:00
|
|
|
|
/** 轻量字符串缓存,默认开启 */
|
|
|
|
|
|
$config['light_cache'] = [
|
2021-01-29 20:47:00 +08:00
|
|
|
|
'size' => 512, //最多允许储存的条数(需要2的倍数)
|
|
|
|
|
|
'max_strlen' => 32768, //单行字符串最大长度(需要2的倍数)
|
2020-12-10 16:37:04 +08:00
|
|
|
|
'hash_conflict_proportion' => 0.6, //Hash冲突率(越大越好,但是需要的内存更多)
|
|
|
|
|
|
'persistence_path' => $config['zm_data'].'_cache.json',
|
2020-11-03 21:02:24 +08:00
|
|
|
|
'auto_save_interval' => 900
|
2021-01-20 16:11:04 +08:00
|
|
|
|
];
|
|
|
|
|
|
|
2021-01-29 20:47:00 +08:00
|
|
|
|
/** 大容量跨进程变量存储(2.2.0可用) */
|
2021-01-20 16:11:04 +08:00
|
|
|
|
$config["worker_cache"] = [
|
|
|
|
|
|
"worker" => 0,
|
|
|
|
|
|
"transaction_timeout" => 30000
|
2020-09-29 15:07:43 +08:00
|
|
|
|
];
|
|
|
|
|
|
|
2020-03-02 16:14:20 +08:00
|
|
|
|
/** MySQL数据库连接信息,host留空则启动时不创建sql连接池 */
|
|
|
|
|
|
$config['sql_config'] = [
|
|
|
|
|
|
'sql_host' => '',
|
|
|
|
|
|
'sql_port' => 3306,
|
|
|
|
|
|
'sql_username' => 'name',
|
|
|
|
|
|
'sql_database' => 'db_name',
|
|
|
|
|
|
'sql_password' => '',
|
2020-06-10 14:39:30 +08:00
|
|
|
|
'sql_options' => [
|
|
|
|
|
|
PDO::ATTR_STRINGIFY_FETCHES => false,
|
|
|
|
|
|
PDO::ATTR_EMULATE_PREPARES => false
|
2020-06-13 10:17:14 +08:00
|
|
|
|
],
|
2020-06-15 19:50:07 +08:00
|
|
|
|
'sql_no_exception' => false,
|
2020-09-29 15:07:43 +08:00
|
|
|
|
'sql_default_fetch_mode' => PDO::FETCH_ASSOC // added in 1.5.6
|
2020-03-02 16:14:20 +08:00
|
|
|
|
];
|
|
|
|
|
|
|
2020-11-03 21:02:24 +08:00
|
|
|
|
/** Redis连接信息,host留空则启动时不创建Redis连接池 */
|
|
|
|
|
|
$config['redis_config'] = [
|
|
|
|
|
|
'host' => '',
|
|
|
|
|
|
'port' => 6379,
|
|
|
|
|
|
'timeout' => 1,
|
|
|
|
|
|
'db_index' => 0,
|
|
|
|
|
|
'auth' => ''
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
/** onebot连接约定的token */
|
|
|
|
|
|
$config["access_token"] = '';
|
2020-03-02 16:14:20 +08:00
|
|
|
|
|
|
|
|
|
|
/** HTTP服务器固定请求头的返回 */
|
|
|
|
|
|
$config['http_header'] = [
|
2021-01-29 20:47:00 +08:00
|
|
|
|
'Server' => 'zhamao-framework',
|
2020-03-02 16:14:20 +08:00
|
|
|
|
'Content-Type' => 'text/html; charset=utf-8'
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
/** HTTP服务器在指定状态码下回复的页面(默认) */
|
|
|
|
|
|
$config['http_default_code_page'] = [
|
|
|
|
|
|
'404' => '404.html'
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
/** zhamao-framework在框架启动时初始化的atomic们 */
|
|
|
|
|
|
$config['init_atomics'] = [
|
2020-09-29 15:07:43 +08:00
|
|
|
|
//'custom_atomic_name' => 0, //自定义添加的Atomic
|
2020-03-02 16:14:20 +08:00
|
|
|
|
];
|
|
|
|
|
|
|
2020-09-29 15:07:43 +08:00
|
|
|
|
/** 终端日志显示等级(0-4) */
|
2020-08-31 10:11:06 +08:00
|
|
|
|
$config["info_level"] = 2;
|
|
|
|
|
|
|
2020-04-15 10:55:10 +08:00
|
|
|
|
/** 上下文接口类 implemented from ContextInterface */
|
|
|
|
|
|
$config['context_class'] = \ZM\Context\Context::class;
|
|
|
|
|
|
|
2020-04-26 17:15:27 +08:00
|
|
|
|
/** 静态文件访问 */
|
|
|
|
|
|
$config['static_file_server'] = [
|
|
|
|
|
|
'status' => false,
|
2020-06-05 13:36:30 +08:00
|
|
|
|
'document_root' => realpath(__DIR__ . "/../") . '/resources/html',
|
2020-04-26 17:15:27 +08:00
|
|
|
|
'document_index' => [
|
|
|
|
|
|
'index.html'
|
|
|
|
|
|
]
|
|
|
|
|
|
];
|
|
|
|
|
|
|
2020-07-11 15:53:30 +08:00
|
|
|
|
/** 注册 Swoole Server 事件注解的类列表 */
|
|
|
|
|
|
$config['server_event_handler_class'] = [
|
2020-08-31 10:11:06 +08:00
|
|
|
|
\ZM\Event\ServerEventHandler::class,
|
2020-07-11 15:53:30 +08:00
|
|
|
|
];
|
|
|
|
|
|
|
2020-09-29 15:07:43 +08:00
|
|
|
|
/** 服务器启用的外部第三方和内部插件 */
|
2020-11-03 21:02:24 +08:00
|
|
|
|
$config['modules'] = [
|
2020-12-14 01:24:34 +08:00
|
|
|
|
'onebot' => [
|
|
|
|
|
|
'status' => true,
|
|
|
|
|
|
'single_bot_mode' => false
|
|
|
|
|
|
], // QQ机器人事件解析器,如果取消此项则默认为 true 开启状态,否则你手动填写 false 才会关闭
|
2020-09-29 15:07:43 +08:00
|
|
|
|
];
|
|
|
|
|
|
|
2020-04-15 10:55:10 +08:00
|
|
|
|
return $config;
|