-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Laravel Workerman * Small change to run CI * [ci skip] Add display_name * Change name index-man.php to start.php * Small change to rerun CI
- Loading branch information
Showing
6 changed files
with
238 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#zend_extension=opcache.so | ||
opcache.enable=1 | ||
opcache.enable_cli=1 | ||
opcache.validate_timestamps=0 | ||
opcache.save_comments=0 | ||
opcache.enable_file_override=1 | ||
opcache.huge_code_pages=1 | ||
|
||
mysqlnd.collect_statistics = Off | ||
|
||
memory_limit = 512M | ||
|
||
opcache.jit_buffer_size = 128M | ||
opcache.jit = tracing | ||
|
||
disable_functions=header,header_remove,headers_sent,http_response_code,setcookie,session_create_id,session_id,session_name,session_save_path,session_status,session_start,session_write_close,set_time_limit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
{ | ||
"name": "laravel/laravel", | ||
"type": "project", | ||
"description": "The Laravel Framework.", | ||
"keywords": [ | ||
"framework", | ||
"laravel" | ||
], | ||
"license": "MIT", | ||
"require": { | ||
"php": "^8.0", | ||
"laravel/framework": "^8.0", | ||
"joanhey/adapterman": "0.4" | ||
}, | ||
"require-dev": { | ||
"facade/ignition": "^2.3.6", | ||
"fzaninotto/faker": "^1.9.1", | ||
"mockery/mockery": "^1.3.1", | ||
"nunomaduro/collision": "^5.0", | ||
"phpunit/phpunit": "^9.3" | ||
}, | ||
"config": { | ||
"optimize-autoloader": true, | ||
"preferred-install": "dist", | ||
"sort-packages": true | ||
}, | ||
"extra": { | ||
"laravel": { | ||
"dont-discover": [] | ||
} | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"App\\": "app/" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"Tests\\": "tests/" | ||
} | ||
}, | ||
"minimum-stability": "dev", | ||
"prefer-stable": true, | ||
"scripts": { | ||
"post-autoload-dump": [ | ||
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump", | ||
"@php artisan package:discover --ansi" | ||
], | ||
"post-root-package-install": [ | ||
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\"" | ||
], | ||
"post-create-project-cmd": [ | ||
"@php artisan key:generate --ansi" | ||
] | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
FROM ubuntu:22.04 | ||
|
||
ARG DEBIAN_FRONTEND=noninteractive | ||
|
||
RUN apt-get update -yqq && apt-get install -yqq software-properties-common > /dev/null | ||
RUN LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php | ||
RUN apt-get update -yqq > /dev/null && \ | ||
apt-get install -yqq git unzip \ | ||
php8.1-cli php8.1-mysql php8.1-mbstring php8.1-xml php8.1-curl > /dev/null | ||
|
||
COPY --from=composer:latest /usr/bin/composer /usr/local/bin/composer | ||
|
||
RUN apt-get install -y php-pear php8.1-dev libevent-dev > /dev/null | ||
RUN pecl install event-3.0.8 > /dev/null && echo "extension=event.so" > /etc/php/8.1/cli/conf.d/event.ini | ||
|
||
ADD ./ /laravel | ||
WORKDIR /laravel | ||
|
||
EXPOSE 8080 | ||
|
||
RUN mkdir -p /laravel/bootstrap/cache /laravel/storage/logs /laravel/storage/framework/sessions /laravel/storage/framework/views /laravel/storage/framework/cache | ||
RUN chmod -R 777 /laravel | ||
|
||
COPY deploy/workerman/composer.json ./ | ||
RUN composer install --optimize-autoloader --classmap-authoritative --no-dev | ||
RUN php artisan optimize | ||
|
||
COPY deploy/conf/cli-php.ini /etc/php/8.1/cli/php.ini | ||
|
||
#RUN sed -i 's|$app->run();|//$app->run();|g' index.php | ||
#RUN sed -i 's|//PDO::ATTR_EMULATE_PREPARES|PDO::ATTR_EMULATE_PREPARES|g' index.php | ||
|
||
CMD php server-man.php start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
require_once __DIR__ . '/vendor/autoload.php'; | ||
|
||
|
||
use Adapterman\Adapterman; | ||
use Workerman\Worker; | ||
use Workerman\Lib\Timer; | ||
|
||
Adapterman::init(); | ||
|
||
$http_worker = new Worker('http://0.0.0.0:8080'); | ||
$http_worker->count = (int) shell_exec('nproc') * 4; | ||
$http_worker->name = 'AdapterMan-Laravel'; | ||
$http_worker->onWorkerStart = function () { | ||
Header::$date = gmdate('D, d M Y H:i:s').' GMT'; | ||
Timer::add(1, function() { | ||
Header::$date = gmdate('D, d M Y H:i:s').' GMT'; | ||
}); | ||
//init(); | ||
require __DIR__.'/start.php'; | ||
}; | ||
|
||
$http_worker->onMessage = static function ($connection, $request) { | ||
|
||
$connection->send(run()); | ||
}; | ||
|
||
Worker::runAll(); | ||
|
||
class Header { | ||
public static $date; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
|
||
/** | ||
* Laravel - A PHP Framework For Web Artisans | ||
* | ||
* @package Laravel | ||
* @author Taylor Otwell <[email protected]> | ||
*/ | ||
|
||
define('LARAVEL_START', microtime(true)); | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Register The Auto Loader | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Composer provides a convenient, automatically generated class loader for | ||
| our application. We just need to utilize it! We'll simply require it | ||
| into the script here so that we don't have to worry about manual | ||
| loading any of our classes later on. It feels great to relax. | ||
| | ||
*/ | ||
|
||
require __DIR__.'/vendor/autoload.php'; | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Turn On The Lights | ||
|-------------------------------------------------------------------------- | ||
| | ||
| We need to illuminate PHP development, so let us turn on the lights. | ||
| This bootstraps the framework and gets it ready for use, then it | ||
| will load up this application so that we can run it and send | ||
| the responses back to the browser and delight our users. | ||
| | ||
*/ | ||
|
||
$app = require_once __DIR__.'/bootstrap/app.php'; | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Run The Application | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Once we have the application, we can handle the incoming request | ||
| through the kernel, and send the associated response back to | ||
| the client's browser allowing them to enjoy the creative | ||
| and wonderful application we have prepared for them. | ||
| | ||
*/ | ||
|
||
global $kernel; | ||
|
||
$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class); | ||
|
||
|
||
function run() | ||
{ | ||
global $kernel; | ||
|
||
ob_start(); | ||
try { | ||
$response = $kernel->handle( | ||
$request = Illuminate\Http\Request::capture() | ||
); | ||
|
||
$response->send(); | ||
header('Date: ' . Header::$date); // To pass the bench, nginx auto add it | ||
|
||
$kernel->terminate($request, $response); | ||
} catch (Throwable $e) { | ||
echo $e->getMessage(); | ||
} | ||
|
||
return ob_get_clean(); | ||
} |