Skip to content

Commit

Permalink
Initialize workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
cclilshy committed Jan 22, 2025
1 parent d4df072 commit a811045
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 9 deletions.
84 changes: 84 additions & 0 deletions .github/workflows/Unix.yml
Original file line number Diff line number Diff line change
@@ -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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
</p>
<p align="center">
<a href="#"><img src="https://img.shields.io/badge/PHP-%3E%3D%208.3-blue" alt="Build Status"></a>
<a href="https://packagist.org/packages/cloudtay/ripple"><img src="https://img.shields.io/packagist/dt/cloudtay/ripple " alt="Download statistics"></a>
<a href="https://packagist.org/packages/cloudtay/ripple"><img src="https://img.shields.io/packagist/v/cloudtay/ripple " alt="Stable version"></a>
<a href="https://packagist.org/packages/cloudtay/ripple"><img src="https://img.shields.io/packagist/l/cloudtay/ripple " alt="License"></a>
<a href="https://packagist.org/packages/cloudtay/ripple"><img src="https://img.shields.io/packagist/dt/cloudtay/ripple" alt="Download statistics"></a>
<a href="https://packagist.org/packages/cloudtay/ripple"><img src="https://img.shields.io/packagist/v/cloudtay/ripple" alt="Stable version"></a>
<a href="https://packagist.org/packages/cloudtay/ripple"><img src="https://img.shields.io/packagist/l/cloudtay/ripple" alt="License"></a>
</p>
<p>
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.
Expand Down
2 changes: 1 addition & 1 deletion src/.env.example
Original file line number Diff line number Diff line change
@@ -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
12 changes: 8 additions & 4 deletions src/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -191,6 +193,7 @@ protected function start(): void
}
});


$monitor = File::getInstance()->monitor();
$monitor->add(base_path('/app'));
$monitor->add(base_path('/bootstrap'));
Expand All @@ -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 () {
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/config/ripple.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
];

0 comments on commit a811045

Please sign in to comment.