Skip to content
This repository has been archived by the owner on Nov 2, 2020. It is now read-only.

Commit

Permalink
refactor(Framework): Rename Mix to Rid
Browse files Browse the repository at this point in the history
  • Loading branch information
Rhilip committed Feb 1, 2019
1 parent 605e111 commit 9c0350d
Show file tree
Hide file tree
Showing 124 changed files with 448 additions and 527 deletions.
46 changes: 29 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## RidPT

A Private Torrent Project based on `MixPHP` framework.
A Private Torrent Project framework.

## Installation Guide

Expand Down Expand Up @@ -39,26 +39,38 @@ edit in Admin Panel.
vi .env
```

5. Run Test by `php bin/mix-httpd service start -u` , And Congratulation If you see those output **without error throwout**.
5. Run Test by `php bin/rid-httpd service start -u` , And Congratulation If you see those output **without error throwout**.

```bash
root@ubuntu-s-4vcpu-8gb-nyc1-01:/home/wwwroot/ridpt.rhilip.info# php bin/mix-httpd service start -u
_____
_______ ___ _____ ___ _____ / /_ ____
__/ __ `__ \/ /\ \/ / / __ \/ __ \/ __ \
_/ / / / / / / /\ \/ / /_/ / / / / /_/ /
/_/ /_/ /_/_/ /_/\_\/ .___/_/ /_/ .___/
/_/ /_/
Server Name: mix-httpd
Framework Version: 1.1.1
PHP Version: 7.2.6
Swoole Version: 4.2.10
Listen Addr: ::
root@ridpt:/data/wwwroot/ridpt.rhilip.info# php bin/rid-httpd service start

────────────────────────────────────────────────────────────────────────────
─████████████████───██████████─████████████───██████████████─██████████████─
─██░░░░░░░░░░░░██───██░░░░░░██─██░░░░░░░░████─██░░░░░░░░░░██─██░░░░░░░░░░██─
─██░░████████░░██───████░░████─██░░████░░░░██─██░░██████░░██─██████░░██████─
─██░░██────██░░██─────██░░██───██░░██──██░░██─██░░██──██░░██─────██░░██─────
─██░░████████░░██─────██░░██───██░░██──██░░██─██░░██████░░██─────██░░██─────
─██░░░░░░░░░░░░██─────██░░██───██░░██──██░░██─██░░░░░░░░░░██─────██░░██─────
─██░░██████░░████─────██░░██───██░░██──██░░██─██░░██████████─────██░░██─────
─██░░██──██░░██───────██░░██───██░░██──██░░██─██░░██─────────────██░░██─────
─██░░██──██░░██████─████░░████─██░░████░░░░██─██░░██─────────────██░░██─────
─██░░██──██░░░░░░██─██░░░░░░██─██░░░░░░░░████─██░░██─────────────██░░██─────
─██████──██████████─██████████─████████████───██████─────────────██████─────
────────────────────────────────────────────────────────────────────────────

Server Name: rid-httpd
System Name: linux
Framework Version: v0.1.2-alpha
PHP Version: 7.2.14
Swoole Version: 4.2.12
Listen Addr: 127.0.0.1
Listen Port: 9501
Hot Update: enabled
Reactor Num: 8
Worker Num: 8
Hot Update: disabled
Coroutine Mode: disabled
Config File: /home/wwwroot/ridpt.rhilip.info/apps/httpd/config/http_permanent.php
Config File: /data/wwwroot/ridpt.rhilip.info/apps/config/http_permanent.php

```

6. Then you can safely add Nginx reserve proxy config like `migration/nginx.conf`.And Notice :
Expand Down
27 changes: 13 additions & 14 deletions apps/commands/ServiceCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

namespace apps\commands;

use Mix\Console\Command;
use Mix\Console\ExitCode;
use Mix\Helpers\ProcessHelper;
use Rid\Console\Command;
use Rid\Console\ExitCode;
use Rid\Helpers\ProcessHelper;

/**
* Service 命令
* @author 刘健 <coder.liu@qq.com>
*/
class ServiceCommand extends Command
{
Expand Down Expand Up @@ -37,19 +36,19 @@ public function optionAliases()
// 初始化事件
public function onInitialize()
{
parent::onInitialize(); // TODO: Change the autogenerated stub
parent::onInitialize();
// 设置pidfile
$this->pidFile = '/var/run/mix-httpd.pid';
$this->pidFile = '/var/run/rid-httpd.pid';
}

// 启动服务
public function actionStart()
{
if ($pid = ProcessHelper::readPidFile($this->pidFile)) {
app()->output->writeln("mix-httpd is running, PID : {$pid}.");
app()->output->writeln("rid-httpd is running, PID : {$pid}.");
return ExitCode::UNSPECIFIED_ERROR;
}
$server = \Mix\Http\HttpServer::newInstanceByConfig('libraries.httpServer');
$server = \Rid\Http\HttpServer::newInstanceByConfig('libraries.httpServer');
if ($this->update) {
$server->settings['max_request'] = 1;
}
Expand All @@ -69,9 +68,9 @@ public function actionStop()
// 等待进程退出
usleep(100000);
}
app()->output->writeln('mix-httpd stop completed.');
app()->output->writeln('rid-httpd stop completed.');
} else {
app()->output->writeln('mix-httpd is not running.');
app()->output->writeln('rid-httpd is not running.');
}
// 返回退出码
return ExitCode::OK;
Expand All @@ -93,10 +92,10 @@ public function actionReload()
ProcessHelper::kill($pid, SIGUSR1);
}
if (!$pid) {
app()->output->writeln('mix-httpd is not running.');
app()->output->writeln('rid-httpd is not running.');
return ExitCode::UNSPECIFIED_ERROR;
}
app()->output->writeln('mix-httpd worker process restart completed.');
app()->output->writeln('rid-httpd worker process restart completed.');
// 返回退出码
return ExitCode::OK;
}
Expand All @@ -105,9 +104,9 @@ public function actionReload()
public function actionStatus()
{
if ($pid = ProcessHelper::readPidFile($this->pidFile)) {
app()->output->writeln("mix-httpd is running, PID : {$pid}.");
app()->output->writeln("rid-httpd is running, PID : {$pid}.");
} else {
app()->output->writeln('mix-httpd is not running.');
app()->output->writeln('rid-httpd is not running.');
}
// 返回退出码
return ExitCode::OK;
Expand Down
4 changes: 2 additions & 2 deletions apps/commands/TimerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

namespace apps\commands;

use Mix\Console\Command;
use Mix\Base\Timer;
use Rid\Console\Command;
use Rid\Base\Timer;

/**
* 定时器范例
Expand Down
42 changes: 21 additions & 21 deletions apps/config/http_base.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
// 路由
'route' => [
// 类路径
'class' => Mix\Http\Route::class,
'class' => Rid\Http\Route::class,
// 默认变量规则
'defaultPattern' => '[\w-]+',
// 路由变量规则
Expand All @@ -43,62 +43,62 @@

// 请求
'request' => [
'class' => Mix\Http\Request::class,
'class' => Rid\Http\Request::class,
],

// 响应
'response' => [
// 类路径
'class' => mix\Http\Response::class,
'class' => Rid\Http\Response::class,
// 默认输出格式
'defaultFormat' => Mix\Http\Response::FORMAT_HTML,
'defaultFormat' => Rid\Http\Response::FORMAT_HTML,
// json
'json' => [
// 类路径
'class' => Mix\Http\Json::class,
'class' => Rid\Http\Json::class,
],
// jsonp
'jsonp' => [
// 类路径
'class' => Mix\Http\Jsonp::class,
'class' => Rid\Http\Jsonp::class,
// callback键名
'name' => 'callback',
],
// xml
'xml' => [
// 类路径
'class' => Mix\Http\Xml::class,
'class' => Rid\Http\Xml::class,
],
],

// 错误
'error' => [
'class' => Mix\Http\Error::class,
'format' => Mix\Http\Error::FORMAT_HTML,
'class' => Rid\Http\Error::class,
'format' => Rid\Http\Error::FORMAT_HTML,
],

// 日志
'log' => [
// 类路径
'class' => Mix\Log\Log::class,
'class' => Rid\Log\Log::class,
// 日志记录级别
'level' => ['emergency', 'alert', 'critical', 'error', 'warning', 'notice', 'info', 'debug'],
// 日志目录
'dir' => 'logs',
// 日志轮转类型
'rotate' => Mix\Log\Log::ROTATE_DAY,
'rotate' => Rid\Log\Log::ROTATE_DAY,
// 最大文件尺寸
'maxFileSize' => 0,
],

// Token
'token' => [
// 类路径
'class' => Mix\Http\Token::class,
'class' => Rid\Http\Token::class,
// 保存处理者
'saveHandler' => [
// 类路径
'class' => Mix\Redis\RedisConnection::class,
'class' => Rid\Redis\RedisConnection::class,
// 主机
'host' => env('REDIS_HOST'),
// 端口
Expand All @@ -119,11 +119,11 @@
// Session
'session' => [
// 类路径
'class' => Mix\Http\Session::class,
'class' => Rid\Http\Session::class,
// 保存处理者
'saveHandler' => [
// 类路径
'class' => Mix\Redis\RedisConnection::class,
'class' => Rid\Redis\RedisConnection::class,
// 主机
'host' => env('REDIS_HOST'),
// 端口
Expand Down Expand Up @@ -154,7 +154,7 @@
// Cookie
'cookie' => [
// 类路径
'class' => Mix\Http\Cookie::class,
'class' => Rid\Http\Cookie::class,
// 过期时间
'expires' => 31536000,
// 有效的服务器路径
Expand All @@ -170,7 +170,7 @@
// 数据库
'pdo' => [
// 类路径
'class' => Mix\Database\PDOConnection::class,
'class' => Rid\Database\PDOConnection::class,
// 数据源格式
'dsn' => env('DATABASE_DSN'),
// 数据库用户名
Expand All @@ -187,7 +187,7 @@
// redis
'redis' => [
// 类路径
'class' => Mix\Redis\RedisConnection::class,
'class' => Rid\Redis\RedisConnection::class,
// 主机
'host' => env('REDIS_HOST'),
// 端口
Expand All @@ -202,11 +202,11 @@
],

'config' => [
'class' => Mix\Config\Config::class,
'class' => Rid\Config\Config::class,
],

'swiftmailer' => [
'class' => Mix\Mailer\Mailer::class,
'class' => Rid\Mailer\Mailer::class,
'host' => env('MAILER_HOST'),
'port' => env('MAILER_PORT'),
'encryption' => env('MAILER_ENCRYPTION'),
Expand All @@ -217,7 +217,7 @@
],

'user' => [
'class' => Mix\User\User::class,
'class' => Rid\User\User::class,
]
],

Expand Down
4 changes: 2 additions & 2 deletions apps/config/http_compatible.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
// 组件配置
'components' => [
'request' => [
'class' => Mix\Http\Compatible\Request::class,
'class' => Rid\Http\Compatible\Request::class,
],

'response' => [
'class' => Mix\Http\Compatible\Response::class,
'class' => Rid\Http\Compatible\Response::class,
],

'error' => [
Expand Down
16 changes: 8 additions & 8 deletions apps/config/http_coroutine.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* mix-httpd 下运行的 HTTP 服务配置(常驻协程模式)
* rid-httpd 下运行的 HTTP 服务配置(常驻协程模式)
*/

$base = include "http_base.php";
Expand All @@ -12,7 +12,7 @@
'token' => [
'saveHandler' => [
// 类路径
'class' => Mix\Redis\Coroutine\RedisConnection::class,
'class' => Rid\Redis\Coroutine\RedisConnection::class,
// 连接池
'connectionPool' => [
// 组件路径
Expand All @@ -24,7 +24,7 @@
// 连接池
'token.connectionPool' => [
// 类路径
'class' => Mix\Pool\ConnectionPool::class,
'class' => Rid\Pool\ConnectionPool::class,
// 最小连接数
'min' => 5,
// 最大连接数
Expand All @@ -36,7 +36,7 @@
// 保存处理者
'saveHandler' => [
// 类路径
'class' => Mix\Redis\Coroutine\RedisConnection::class,
'class' => Rid\Redis\Coroutine\RedisConnection::class,
// 连接池
'connectionPool' => [
// 组件路径
Expand All @@ -48,7 +48,7 @@
// 连接池
'session.connectionPool' => [
// 类路径
'class' => Mix\Pool\ConnectionPool::class,
'class' => Rid\Pool\ConnectionPool::class,
// 最小连接数
'min' => 5,
// 最大连接数
Expand All @@ -58,7 +58,7 @@
// 数据库
'pdo' => [
// 类路径
'class' => Mix\Database\Coroutine\PDOConnection::class,
'class' => Rid\Database\Coroutine\PDOConnection::class,
// 连接池
'connectionPool' => [
// 组件路径
Expand All @@ -69,7 +69,7 @@
// 连接池
'pdo.connectionPool' => [
// 类路径
'class' => Mix\Pool\ConnectionPool::class,
'class' => Rid\Pool\ConnectionPool::class,
// 最小连接数
'min' => 5,
// 最大连接数
Expand All @@ -79,7 +79,7 @@
// redis
'redis' => [
// 类路径
'class' => Mix\Redis\Coroutine\RedisConnection::class,
'class' => Rid\Redis\Coroutine\RedisConnection::class,
// 连接池
'connectionPool' => [
// 组件路径
Expand Down
Loading

0 comments on commit 9c0350d

Please sign in to comment.