dooaki / test-groonga_server
测试用的 Groonga 服务器运行器
Requires
- ext-posix: *
- dooaki/net-empty_port: 0.0.*
Requires (Dev)
- phpunit/phpunit: 4.2.*
- satooshi/php-coveralls: dev-master
This package is not auto-updated.
Last update: 2024-09-24 03:02:54 UTC
README
测试用的 Groonga 服务器运行器
需求
- PHP 5.3 或更高版本
- Groonga
概要
<?php use dooaki\Test\GroongaServer; $server = new GroongaServer(array('protocol' => 'http')); $server->run(); $fp = stream_socket_client("tcp://:{$server->getPort()}"); fwrite("GET /d/status HTTP/1.0\r\n\r\n"); while (!feof($fp)) { echo fgets($fp, 1024); } fclose($fp);
安装
您可以使用 Composer 安装此脚本。
在您的 composer.json 文件中
{
"require": {
"dooaki/test-groonga_server": "dev-master"
}
}
composer.phar install
启动选项
您可以在构造函数中更改 Groonga 服务器的启动选项
示例
new GroongaServer(array( 'protocol' => 'gqtp', 'encoding' => 'euc', ));
-
db
您可以指定现有数据库文件。如果指定了该文件,则包含该文件的目录将成为
工作目录。 -
tempdir
如果您没有指定 db,则可以指定
工作目录的存储位置。默认使用sys_get_temp_dir()。 -
protocol (--protocol)
指定协议
http或gqtp(默认:http) -
port (--port)
指定服务器端口。如果不指定,将自动搜索可用端口。
-
pid-path (--pid-path)
指定存储服务器进程ID的文件。如果指定绝对路径,则使用该文件;否则,使用从工作目录的相对路径。启动前将被删除(默认: 'pid')。
-
log-path (--log-path)
指定日志文件的存储位置。如果指定绝对路径,则使用该文件;否则,使用从工作目录的相对路径(默认: 'log')。
-
query-log-path (--query-log-path)
如果记录查询日志,则指定查询日志文件的存储位置。如果指定绝对路径,则使用该文件;否则,使用从工作目录的相对路径(默认: 无指定)。
以下选项指定时,将直接传递给各自的启动选项。有关每个选项的说明,请参阅 groonga 命令的说明
- encoding (--encoding)
- log-level (--log-level)
- bind-address (--bind-address)
- server-id (--server-id)
- document-root (--document-root)
- max-threads (--max-thread)
- config-path (--config-path)
- cache-limit (--cache-limit)
- default-match-escalation-threshold (--default-match-escalation-threshold)
方法
class dooaki\Test\GroongaServer
run()
启动 Groonga 服务器。如果您在构造函数中没有指定 db 并执行它,则将创建一个临时工作目录并在其中创建 DB 文件。临时工作目录将在对象被销毁时自动删除。
getPid()
返回服务器的进程ID
getWorkDir()
返回 工作目录
getPort()
返回服务器的端口号
getDb()
返回服务器打开的 DB 文件
getLogFile()
返回日志文件的路径
getQueryLogFile()
返回查询日志文件的路径
作者
do_aki <do.hiroaki at gmail.com>
许可证
MIT 许可证