From a8110455b5b841bfd47f649f8d795d22fd6a6378 Mon Sep 17 00:00:00 2001
From: cclilshy
Date: Wed, 22 Jan 2025 13:08:21 +0800
Subject: [PATCH] Initialize workflows
---
.github/workflows/Unix.yml | 84 ++++++++++++++++++++++++++++++++++++++
README.md | 6 +--
src/.env.example | 2 +-
src/Console.php | 12 ++++--
src/config/ripple.php | 2 +-
5 files changed, 97 insertions(+), 9 deletions(-)
create mode 100644 .github/workflows/Unix.yml
diff --git a/.github/workflows/Unix.yml b/.github/workflows/Unix.yml
new file mode 100644
index 0000000..f62813b
--- /dev/null
+++ b/.github/workflows/Unix.yml
@@ -0,0 +1,84 @@
+name: test-Unix
+
+on:
+ workflow_dispatch:
+ push:
+ branches:
+ - main
+ pull_request:
+ branches:
+ - main
+
+jobs:
+ test-unix:
+ runs-on: ${{ matrix.os }}
+
+ strategy:
+ matrix:
+ os: [ ubuntu-latest ]
+ php: [ '8.2','8.3','8.4' ]
+
+ steps:
+ # 检出代码
+ - uses: actions/checkout@v3
+
+ # 安装 PHP 和扩展
+ - name: Setup PHP
+ uses: shivammathur/setup-php@v2
+ with:
+ php-version: ${{ matrix.php }}
+ extensions: posix, sockets, pcntl, openssl, curl, ev, fileinfo, sqlite3
+
+ # 安装Apache Benchmark
+ - name: Install Apache Benchmark
+ run: |
+ sudo apt-get update
+ sudo apt-get install apache2-utils -y
+
+ # 安装 Composer 依赖
+ - name: Install Laravel
+ run: |
+ composer install
+ composer create-project --prefer-dist laravel/laravel app "^11.0"
+
+ # 配置 Laravel 引擎插件
+ - name: Initialize ripple
+ working-directory: app
+ run: |
+ composer config repositories.local-plugin path ../
+ composer require cloudtay/laravel-ripple:dev-main
+
+ # 初始化测试路由
+ - name: Initialize Test Route
+ working-directory: app
+ run: |
+ echo "RIP_HTTP_LISTEN=http://127.0.0.1:8008" >> .env
+ echo "RIP_HTTP_WORKERS=1" >> .env
+ php artisan vendor:publish --tag=ripple-config
+ php artisan optimize
+
+ # 启动引擎服务
+ - name: Start Server
+ working-directory: app
+ run: |
+ php artisan ripple:server start > server.log 2>&1 &
+ echo $! > server.pid
+ sleep 10
+
+ # 访问测试
+ - name: Run Test
+ working-directory: app
+ run: |
+ curl http://127.0.0.1:8008/ > curl.log
+
+ # 压力测试
+ - name: Run Stress testing
+ working-directory: app
+ run: |
+ ab -n 1000 -c 20 -k http://127.0.0.1:8008/
+
+ # 关闭服务
+ - name: Stop Server
+ working-directory: app
+ run: |
+ php artisan ripple:server stop
diff --git a/README.md b/README.md
index 199502d..de7fec3 100644
--- a/README.md
+++ b/README.md
@@ -3,9 +3,9 @@
-
-
-
+
+
+
ripple is a modern, high-performance native PHP coroutine framework designed to solve PHP's challenges in high concurrency, complex network communication and data operations.
diff --git a/src/.env.example b/src/.env.example
index f0fbcc2..e8cc802 100644
--- a/src/.env.example
+++ b/src/.env.example
@@ -1,3 +1,3 @@
RIP_HTTP_LISTEN=http://127.0.0.1:8008
RIP_HTTP_WORKERS=4
-RIP_HTTP_RELOAD=0
+RIP_HTTP_RELOAD=1
diff --git a/src/Console.php b/src/Console.php
index c8059f4..6138490 100644
--- a/src/Console.php
+++ b/src/Console.php
@@ -13,6 +13,8 @@
namespace Ripple\Driver\Laravel;
use Illuminate\Console\Command;
+use Illuminate\Support\Facades\Config;
+use JetBrains\PhpStorm\NoReturn;
use Revolt\EventLoop\UnsupportedFeatureException;
use Ripple\Channel\Channel;
use Ripple\Driver\Laravel\Virtual\Virtual;
@@ -191,6 +193,7 @@ protected function start(): void
}
});
+
$monitor = File::getInstance()->monitor();
$monitor->add(base_path('/app'));
$monitor->add(base_path('/bootstrap'));
@@ -204,7 +207,10 @@ protected function start(): void
$monitor->onModify = fn () => $this->reload();
$monitor->onTouch = fn () => $this->reload();
$monitor->onRemove = fn () => $this->reload();
- $monitor->run();
+
+ if (Config::get('ripple.HTTP_RELOAD', 1)) {
+ $monitor->run();
+ }
try {
onSignal(SIGINT, function () {
@@ -228,10 +234,8 @@ protected function start(): void
/**
* @return void
*/
- protected function stop(): void
+ #[NoReturn] protected function stop(): void
{
-
-
$channel = channel(base_path());
$channel->send('stop');
exit(0);
diff --git a/src/config/ripple.php b/src/config/ripple.php
index d7608fd..7f5bf46 100644
--- a/src/config/ripple.php
+++ b/src/config/ripple.php
@@ -16,5 +16,5 @@
return [
'HTTP_LISTEN' => Env::get('RIP_HTTP_LISTEN', 'http://127.0.0.1:8008'),
'HTTP_WORKERS' => Env::get('RIP_HTTP_WORKERS', 4),
- 'HTTP_RELOAD' => Env::get('RIP_HTTP_RELOAD', 0)
+ 'HTTP_RELOAD' => Env::get('RIP_HTTP_RELOAD', 1)
];