ensi / octane-swoole-urgent-starter
Laravel octane swoole urgent starter
Installs: 28 792
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: ^8.1
- laravel/octane: ^2.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.2
- nunomaduro/collision: ^6.0 || ^7.0 || ^8.1
- orchestra/testbench: ^7.0 || ^8.0 || ^9.0
- pestphp/pest: ^1.22 || ^2.0
- pestphp/pest-plugin-laravel: ^1.1 || ^2.0
- phpstan/extension-installer: ^1.3
- phpstan/phpstan: ^1.11
- spaze/phpstan-disallowed-calls: ^2.15
This package is auto-updated.
Last update: 2024-10-27 09:15:14 UTC
README
This package adds alternative behaviour to octane server for dev and prod usage.
Dev: server process continue work even if syntax error appears in code.
Prod: you can start swoole master process directly, without artisan command, which consumes some memory.
Installation
You can install the package via composer:
composer require ensi/octane-swoole-urgent-starter
and add this section to config/octane.php file
'swoole' => [
'command' => '/var/www/vendor/bin/urgent-swoole-server',
'show_fatal_error' => env('OCTANE_SHOW_FATAL_ERROR', false),
]
Version Compatibility
Basic Usage
Dev
Just start octane server with swoole backend and --watch option,
and see how it reloads after very fatal errors.
If you want to see error message in http response, set true
to OCTANE_SHOW_FATAL_ERROR
environment variable.
Prod
Originally, octane:start
command makes server state file and then starts swoole process as child.
Now you can to separate this to two steps.
First: use octane:dump-server-state
command for saving server state file.
Second: start swoole process, without any useless parent.
php artisan octane:dump-server-state --host=0.0.0.0 --port=8000 --workers=20 export APP_ENV=production export APP_BASE_PATH=/var/www export LARAVEL_OCTANE=1 php ./vendor/bin/swoole-server /var/www/storage/logs/octane-server-state.json
When service works in ELC workspace
Old elc workspace template uses hack for reloading code without container restarts. You should to replace last artisan command in templates/swoole-X.X/php/entrypoint to this
OCTANE_SHOW_FATAL_ERROR=true php artisan octane:swoole --watch --host=0.0.0.0 --workers=1 --task-workers=1 || sleep 3600
Contributing
Please see CONTRIBUTING for details.
Testing
- composer install
- composer test
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
License
The MIT License (MIT). Please see License File for more information.