Coder Social home page Coder Social logo

laravoole's Introduction

Laravoole

Laravel on Swoole Or Workerman

10x faster than php-fpm

Latest Stable Version Total Downloads Latest Unstable Version License Build Status Code Coverage

Depends On

php>=5.5.16
laravel/laravel^ 5.1

Suggests

php>=7.0.0
ext-swoole>=1.7.21
workerman/workerman>=3.0

Install

To get started, add laravoole to you composer.json file and run composer update:

"garveen/laravoole": "^0.5.0"

or just run shell command:

 composer require garveen/laravoole

Once composer done its job, you need to register Laravel service provider, in your config/app.php:

'providers' => [
    ...
    Laravoole\LaravooleServiceProvider::class,
],

Notice: You should NOT use file session handler, because it is not stable at this environement. Use redis or other handler instead.

Usage

php artisan laravoole [start | stop | reload | reload_task | restart | quit]

Migrations

Upgrade to 0.4

Event names has changed:

  • laravoole.on_request => laravoole.requesting
  • laravoole.on_requested => laravoole.requested
  • laravoole.swoole.websocket.on_close => laravoole.swoole.websocket.closing

Config

To generate config/laravoole.php:

php artisan vendor:publish --provider="Laravoole\LaravooleServiceProvider"

Most of things can be configured with .env, and you should use LARAVOOLE_{UPPER_CASE} format, for example,

[
    'base_config' => [
        'host' => '0.0.0.0',
    ]
]

is equals with

LARAVOOLE_HOST=0.0.0.0

Events

You can handle events by editing EventServiceProvider:

public function boot()
{
    parent::boot();
    \Event::listen('laravoole.requesting', function ($request) {
        \Log::info($request->segments());
    });
}
  • laravoole.requesting(Illuminate\Http\Request)
  • laravoole.requested(Illuminate\Http\Request, Illuminate\Http\Response)
  • laravoole.swoole.websocket.closing(Laravoole\Request, int $fd)

base_config

This section configures laravoole itself.

mode

SwooleHttp uses swoole to response http requests

SwooleFastCGI uses swoole to response fastcgi requests (just like php-fpm)

SwooleWebSocket uses swoole to response websocket requests AND http requests

WorkermanFastCGI uses workerman to response fastcgi requests (just like php-fpm)

user defined wrappers

You can make a new wrapper implements Laravoole\Wrapper\ServerInterface, and put its full class name to mode.

pid_file

Defines a file that will store the process ID of the main process.

deal_with_public

When using Http mode, you can turn on this option to let laravoole send static resources to clients. Use this ONLY when developing.

host and port

Default host is 127.0.0.1, and port is 9050

handler_config

This section configures the backend, e.g. swoole or workerman.

Swoole

As an example, if want to set worker_num to 8, you can set .env:

 LARAVOOLE_WORKER_NUM=8

or set config/laravoole.php:

[
    'handler_config' => [
        'worker_num' => 8,
    ]
]

See Swoole's document:

简体中文

English

Workerman

As an example, if want to set worker_num to 8, you can set .env:

 LARAVOOLE_COUNT=8

or set config/laravoole.php:

[
    'handler_config' => [
        'count' => 8,
    ]
]

See Workerman's document:

简体中文

English

Websocket Usage

Subprotocols

See Mozilla's Document: Writing WebSocket server

The default subprotocol is jsonrpc, but has some different: params is an object, and two more properties:

status as HTTP status code

method is the same as request's method

You can define your own subprotocol, by implements Laravoole\WebsocketCodec\CodecInterface and add to config/laravoole.php.

Client Example:

<!DOCTYPE html>
<meta charset="utf-8" />
<title>WebSocket Test</title>
<style>
p{word-wrap: break-word;}
tr:nth-child(odd){background-color: #ccc}
tr:nth-child(even){background-color: #eee}
</style>
<h2>WebSocket Test</h2>
<table><tbody id="output"></tbody></table>
<script>
    var wsUri = "ws://localhost:9050/websocket";
    var protocols = ['jsonrpc'];
    var output = document.getElementById("output");

    function send(message) {
        websocket.send(message);
        log('Sent', message);
    }

    function log(type, str) {
        str = str.replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/'/g, '&#39;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
        output.insertAdjacentHTML('beforeend', '<tr><td>' + type + '</td><td><p>' + htmlEscape(str) + '</p></td></tr>');
    }

    websocket = new WebSocket(wsUri, protocols);
    websocket.onopen = function(evt) {
        log('Status', "Connection opened");
        send(JSON.stringify({method: '/', params: {hello: 'world'},  id: 1}));
        setTimeout(function(){ websocket.close() },1000)
    };
    websocket.onclose = function(evt) { log('Status', "Connection closed") };
    websocket.onmessage = function(evt) { log('<span style="color: blue;">Received</span>', evt.data) };
    websocket.onerror = function(evt) {  log('<span style="color: red;">Error</span>', evt.data) };
</script>
</html>

Work with nginx

server {
    listen       80;
    server_name  localhost;

    root /path/to/laravel/public;

    location / {
            try_files $uri $uri/ @laravoole;
            index  index.html index.htm index.php;
        }

    # http
    location @laravoole {
        proxy_set_header   Host $host:$server_port;
        proxy_set_header   X-Real-IP $remote_addr;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_http_version 1.1;

        proxy_pass http://127.0.0.1:9050;
    }

    # fastcgi
    location @laravoole {
        include fastcgi_params;
        fastcgi_pass 127.0.0.1:9050;
    }

    # websocket
    # send close if there has not an upgrade header
    map $http_upgrade $connection_upgrade {
        default upgrade;
        '' close;
    }
    location /websocket {
        proxy_connect_timeout 7d;
        proxy_send_timeout 7d;
        proxy_read_timeout 7d;
        proxy_pass http://127.0.0.1:9050;
        proxy_http_version 1.1;
        proxy_set_header Upgrade    $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
    }
}

License

MIT

laravoole's People

Contributors

chekun avatar chxj1992 avatar denghongcai avatar garveen avatar hhxsv5 avatar xhinliang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravoole's Issues

关于事件名变更问题

Hi,
laravoole.on_request更名为laravoole.requesting,因此项目已用于生产,所以此次影响较大,不过现在开始锁版本。

关于文档中的版本锁定:之前~0.2 表示>=0.2 && <=1.0,导致composer update时直接回升级到0.4.1。

所以建议使用~0.4.1锁定到三级版本号,>=0.4.1&&<=0.5

谢谢!

feature: customized wrapper class support

It's an awesome package!
But sometimes I'd like to make some change on a wrapper to satisfy my own requirements (like doing someting before the swoole server started). So I think implement my wrapper might be a good idea.
And I also created a pr for this. 😁
#27

都是错误

[Exception]
Address 127.0.0.1:9050 already in use

安装报错,求助

Problem 1
- Can only install one of: symfony/psr-http-message-bridge[v1.0.0, v0.2].
- Can only install one of: symfony/psr-http-message-bridge[v1.0.0, v0.2].
- Can only install one of: symfony/psr-http-message-bridge[v1.0.0, v0.2].
- garveen/laravoole 0.5.1 requires symfony/psr-http-message-bridge ^1.0 -> satisfiable by symfony/psr-http-message-bridge[v1.0.0].
- Installation request for garveen/laravoole ^0.5.1 -> satisfiable by garveen/laravoole[0.5.1].
- Installation request for symfony/psr-http-message-bridge (locked at v0.2) -> satisfiable by symfony/psr-http-message-bridge[v0.2].

SwooleFastCGI上传文件报错

laravoole v0.5.1,Laravel 5.1,Swoole 1.9.8,openresty 1.11.2.2

其他 web 请求正常,上传文件时出错。

以 multipart/form-data 方式上传文件。使用 Illuminate\Http\Request->hasFile() 检查文件,以及 Illuminate\Http\Request->file() 获取文件信息。

错误日志如下:

[2017-03-30 00:36:45] development.ERROR: Symfony\Component\Debug\Exception\FatalErrorException: Uncaught ErrorException: A non-numeric value encountered in /xxx/vendor/garveen/fastcgi/src/FastCgiRequest.php:265
Stack trace:
#0 /xxx/vendor/garveen/fastcgi/src/FastCgiRequest.php(265): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'A non-numeric v...', '/xxx...', 265, Array)
#1 /xxx/vendor/garveen/fastcgi/src/FastCgiRequest.php(198): Garveen\FastCgi\FastCgiRequest->parseFormData('----WebKitFormB...')
#2 /xxx/vendor/garveen/fastcgi/src/FastCgiRequest.php(132): Garveen\FastCgi\FastCgiRequest->parseBody()
#3 /xxx/vendor/garveen/fastcgi/src/FastCgi.php(151): Garveen\FastCgi\FastCgiRequest->parse()
#4 /xxx/vendor/garveen/laravoole/src/Wrapper/SwooleFastCGIWrapper.php(36): Garveen\FastCgi\FastCgi->receive(342, '\x01\x01\x00\x01\x00\x08\x00\x00\x00 in /xxx/vendor/garveen/fastcgi/src/FastCgiRequest.php:265
Stack trace:
#0 {main}--

是不是目前还不支持文件上传?

Could not find package acabin/laravoole

When I install for errors.
composer require acabin/laravoole

[InvalidArgumentException]
Could not find package acabin/laravoole at any version for your minimum-stability (stable). Check the package spelling or your minimum-stability

Is it possible to add some hooks when worker process deal with onReqeust method?

// vendor/garveen/laravoole/src/Base.php
......
$kernel = $this->kernel;

// do some others action before deal request
if (isset($this->wrapper_config['on_before_deal_request_cb']) && Arr::accessible($this->wrapper_config['on_before_deal_request_cb'])) {
    $dealActions = $this->wrapper_config['on_before_deal_request_cb'];
    foreach ($dealActions as $action) {
        if (is_callable($action)) {
            call_user_func($action, [$this->app]);
        }
    }
}

if (!$illuminate_request) {
    $illuminate_request = $this->dealWithRequest($request);
}
......

Is it possible to add some hooks when worker process deal with onReqeust method?

Thanks author to offer this nice package. Ur... Can you speak Chinese?

Empty POST data

When I send POST request $request->get('field') is null but in GET request all works fine.
Little hack: $data = $request->all();
$data['field'] work.
Any ideas?

'Undefined offset: 24670' in /xxxxx/vendor/garveen/laravoole/src/Protocol/FastCGI.php:113

  [Symfony\Component\Debug\Exception\FatalErrorException]                                                                                                                                                            
  Uncaught exception 'ErrorException' with message 'Undefined offset: 24670' in /xxxxx/vendor/garveen/laravoole/src/Protocol/FastCGI.php:113                                                  
  Stack trace:                                                                                                                                                                                                       
  #0 /xxxxx/vendor/garveen/laravoole/src/Protocol/FastCGI.php(113): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8, 'Undefined offse...', '/Users/ql/wwwro...', 113, Array)  
  #1 /xxxxx/vendor/garveen/laravoole/src/Wrapper/SwooleFastCGIWrapper.php(33): Laravoole\Wrapper\SwooleFastCGIWrapper->receive(4, '\xE1\x84\xA7\x12e\xBA\x94YRfD\x99\x16e\xB6...')            
  #2 [internal function]: Laravoole\Wrapper\SwooleFastCGIWrapper->onReceive(Object(swoole_server), 4, 0, '\xE1\x84\xA7\x12e\xBA\x94YRfD\x99\x16e\xB6...')                                                            
  #3 /xxxxx/vendor/garveen/laravoole/src/Wrapper/SwooleFastCGIWrapper.php(28): swoole_server->start()                                                                                         
  #4 /xxxxx/vendor/garveen/laravoole/src/Server.php(27): Laravoole\Wrapper\SwooleFastCGIWrapper->start()                                                                                      
  #5 /xxxxx/vendo                                                                                                                                                                             

[2017-01-16 11:03:54 *73301.0]  ERROR   zm_deactivate_swoole (ERROR 103): Fatal error: Uncaught exception 'ErrorException' with message 'Undefined offset: 24670' in /xxxxx/vendor/garveen/laravoole/src/Protocol/FastCGI.php:113
Stack trace:
#0 /xxxxx/vendor/garveen/laravoole/src/Protocol/FastCGI.php(113): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8, 'Undefined offse...', '/Users/ql/wwwro...', 113, Array)
#1 /xxxxx/vendor/garveen/laravoole/src/Wrapper/SwooleFas
[2017-01-16 11:03:54 $73240.0]  WARNING swManager_check_exit_status: worker#0 abnormal exit, status=255, signal=0
Unexpected FastCGI-record #. Request ID: 4
Unexpected FastCGI-record #. Request ID: 4
Unexpected FastCGI-record #. Request ID: 4
Unexpected FastCGI-record #. Request ID: 4
Unexpected FastCGI-record #. Request ID: 4

大文件上传,用了分片上传,每个分片3M, 只有部分分片能够上传成功,
max_request改大了也没用~

服务器端口配置期望支持socket unix://协议

load balancer <=> nginx <=> swoole fastcgi 模式。

lb 与 nginx 保持长连接。而 nginx 与 swoole fastcgi 暂时无法保持长连接。
高并发时,如果使用 swoole tcp 模式,会受到临时端口数限制,如果没有及时清理,服务器上端口极有可能不够用。
建议 new swoole_server 时,支持配置成 /dev/shm/laravoole.sock 这样的unix socket 地址。

可以config直接配置成 listen,例如:

tcp://127.0.0.1:9050
unix:/dev/shm/laravoole.sock

服务开启不成功?

[2017-07-13 09:46:22 #29484.0] NOTICE Server is shutdown now.
[2017-07-13 10:41:23 #30535.0] NOTICE Server is shutdown now.
[2017-07-13 10:42:02 #31229.0] NOTICE Server is shutdown now.
[2017-07-14 01:40:13 #2603.0] NOTICE Server is shutdown now.

PHP Fatal error: Uncaught exception 'ReflectionException' with message 'Class App\Http\Kernel does not exist'

Hi,

If I changed Laravel root namespace like php artisan app:name "Passport"
Then composer.json

{
"autoload": {
    "classmap": [
      "database"
    ],
    "psr-4": {
      "Passport\\": "app/"
    }
  }
}

But, there is hard code in file Base.php line 208

$app->singleton(
    \Illuminate\Contracts\Http\Kernel::class,
    \App\Http\Kernel::class
);

$app->singleton(
    \Illuminate\Contracts\Console\Kernel::class,
    \App\Console\Kernel::class
);

$app->singleton(
    \Illuminate\Contracts\Debug\ExceptionHandler::class,
    \App\Exceptions\Handler::class
);

Mysql连接池

是否有计划令Laravel有数据库连接池功能?

监听多个端口,运行在不同的模式

想用 laravoole 做几个事情,监听多个端口,使用多种协议。

例如启动一个 laravoole,监听 9050 端口,解析 FastCGI 协议。
再启动一个 laravoole,监听 9051 端口,解析 WebSocket 协议。

我想了下,是不是 laravoole config 需要增加一个 group 概念。兼容历史版本,以前的就放在 default group

[
   'group1' => [
      'base_config' => [
        'host' => '',
        'port' => '9050',
      ]
   ],
   'group2' => [
      'base_config' => [
        'host' => '',
        'port' => '9051',
      ]
   ]
]

命令

php artisan laravoole [start|stop|reload] --group=group1

SwooleFastCGI模式无响应

laravoole v0.5.1,Laravel 5.1,Swoole 1.9.8,openresty 1.11.2.2

配置成 SwooleFastCGI 可以正常启动。发送请求后,出现长时间无响应,最终超时 504 错误。

看了下日志,出现如下错误:

PHP Fatal error:  Uncaught ErrorException: fwrite(): send of 51 bytes failed with errno=88 Socket operation on non-socket in /xxxx/vendor/garveen/laravoole/src/Wrapper/SwooleFastCGIWrapper.php:65

src/Wrapper/SwooleFastCGIWrapper.php 第65行 onWorkerStart 方法中的 fwrite(STDOUT, "$level $info"); 注释掉就正常了

larahole

10x faster? It's a LIE! Show bench

error occurred in workerman and laravel5.3

////======composer.json
{
"require": {
"php": ">=5.6.4",
"garveen/laravoole": "dev-master",
"laravel/framework": "5.3.",
"predis/predis": "~1.0",
"guzzlehttp/guzzle": "~6.0",
"barryvdh/laravel-ide-helper": "~2.2",
"workerman/workerman": "^3.3"
},
"require-dev": {
"fzaninotto/faker": "~1.4",
"mockery/mockery": "0.9.
",
"phpunit/phpunit": "~5.0",
"symfony/css-selector": "3.1.",
"symfony/dom-crawler": "3.1.
"
},
"autoload": {
"classmap": [
"database"
],
"psr-4": {
"App\": "app/"
}
},
"autoload-dev": {
"classmap": [
"tests/TestCase.php"
]
},
"scripts": {
"post-root-package-install": [
"php -r "file_exists('.env') || copy('.env.example', '.env');""
],
"post-create-project-cmd": [
"php artisan key:generate"
],
"post-install-cmd": [
"Illuminate\Foundation\ComposerScripts::postInstall",
"php artisan optimize"
],
"post-update-cmd": [
"Illuminate\Foundation\ComposerScripts::postUpdate",
"php artisan optimize"
]
},
"config": {
"preferred-install": "dist"
}
}
======//////

//////======php artisan laravoole start====stdout
PHP Notice: Use of undefined constant COMPOSER_INSTALLED - assumed 'COMPOSER_INSTALLED' in /home/wwwroot/sowechat/vendor/garveen/laravoole/src/Wrapper/WorkermanFastCGIWrapper.php on line 13
PHP Warning: require(./workerman/workerman/Autoloader.php): failed to open stream: No such file or directory in /home/wwwroot/sowechat/vendor/garveen/laravoole/src/Wrapper/WorkermanFastCGIWrapper.php on line 13
PHP Fatal error: require(): Failed opening required './workerman/workerman/Autoloader.php' (include_path='.:/usr/local/php/lib/php') in /home/wwwroot/sowechat/vendor/garveen/laravoole/src/Wrapper/WorkermanFastCGIWrapper.php on line 13
======//////

运行一段时间后性能开始降低

Hi garveen,
最近升级laravoole后,发现运行一段时间后,性能开始降低,耗时从最初的60ms增加的2s,每次restart后才恢复正常,但好景不长。

laravoole 5.1, swoole 1.9.6

一张请求耗时图,其中接近18点时进行了restart。
image

我首先考虑到的是内存问题,然后分别在restart后和出问题时得到了内存占用情况。
刚开始运行时的内存占用:
1

性能降低时的内存占用:
2

确实内存增量很大,然后开始检查业务代码有没有内存泄漏隐患,但没发现
swoole内存管理

所以考虑是不是laravoole这层有问题,比如在clean中需要unset清理一些大数组、容器、实例。

请协助一起看看。

谢谢!

求助,使用SwooleWebSocket怎么配置和响应请求

配置了:

#laravoole
LARAVOOLE_MODE=SwooleWebSocket

可以正常启动服务,但是监听不到响应的事件,也不知道如何返回相应的response

        \Event::listen(
            'laravoole.requesting',
            function ($request) {
                Logger::getLogger('laravoole_dev')->info('11');
                //                Logger::getLogger('laravoole_dev')->info(PHP_EOL . json_encode($request) . PHP_EOL);
            }
        );

        \Event::listen(
            'laravoole.requested',
            function ($request, $response) {
                Logger::getLogger('laravoole_dev')->info('11');
                //                Logger::getLogger('laravoole_dev')->info(PHP_EOL . json_encode($request) . PHP_EOL);
                return $response;
            }
        );

Invalid argument supplied for foreach()

PHP版本:
PHP 7.1.10 (cli) (built: Oct 25 2017 09:42:03) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.1.10, Copyright (c) 1999-2017, by Zend Technologies
swoole版本:
swoole support => enabled
Version => 1.9.20
Author => tianfeng.han[email: [email protected]]
epoll => enabled
eventfd => enabled
timerfd => enabled
signalfd => enabled
cpu affinity => enabled
spinlock => enabled
rwlock => enabled
async http/websocket client => enabled
Linux Native AIO => enabled
pcre => enabled
zlib => enabled
mutex_timedlock => enabled
pthread_barrier => enabled
futex => enabled

Directive => Local Value => Master Value
swoole.aio_thread_num => 2 => 2
swoole.display_errors => On => On
swoole.use_namespace => Off => Off
swoole.fast_serialize => Off => Off
swoole.unixsock_buffer_size => 8388608 => 8388608

切换服务器,部署后就出现以下报错。。。

不知道发生了什么事情。日志记录到的报错信息:
[2017-10-30 08:39:49] local.ERROR: Symfony\Component\Debug\Exception\FatalErrorException: Uncaught ErrorException: Invalid argument supplied for foreach() in /data/wwwroot/huahui/vendor/garveen/laravoole/src/Request.php:118
Stack trace:
#0 /data/wwwroot/huahui/vendor/garveen/laravoole/src/Request.php(118): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(2, 'Invalid argumen...', '/data/wwwroot/h...', 118, Array)
#1 /data/wwwroot/huahui/vendor/garveen/laravoole/src/Request.php(130): Laravoole\Request->destoryTempFiles()
#2 /data/wwwroot/huahui/vendor/garveen/laravoole/src/Wrapper/SwooleWebSocketWrapper.php(225): Laravoole\Request->__destruct()
#3 [internal function]: Laravoole\Wrapper\SwooleWebSocketWrapper->onClose(Object(swoole_websocket_server), 770, 1)
#4 /data/wwwroot/huahui/vendor/garveen/laravoole/src/Wrapper/Swoole.php(71): swoole_http_server->start()
#5 /data/wwwroot/huahui/vendor/garveen/laravoole/src/Wrapper/SwooleHttpWrapper.php(26): Laravoole\Wrapper\Swoole->start()
#6 /data/wwwroot/huahui/vendor/garveen/laravoole/src/Wrapper/SwooleWebSocketWrapper.php(68): Laravoole\Wrapp in /data/wwwroot/huahui/vendor/garveen/laravoole/src/Request.php:118
Stack trace:
#0 {main}

配置成 systemd 服务

保存 service 配置文件,注意修改 User、Group,PIDFile 与 php、artisan 绝对路径。

cat << "EOF" | sudo tee /lib/systemd/system/laravoole.service
[Unit]
Description=Laravoole
After=network.target

[Service]
User=nobody
Group=nogroup
LimitCORE=infinity
LimitNOFILE=262140
LimitNPROC=262140
Type=forking
PIDFile=/dev/shm/laravoole.pid
ExecStart=/usr/local/bin/php /xxx/artisan laravoole start
ExecReload=/usr/local/bin/php /xxx/artisan laravoole reload
ExecStop=/usr/local/bin/php /xxx/artisan laravoole stop
Restart=on-failure
RestartSec=3s

[Install]
WantedBy=multi-user.target
EOF

然后执行

systemctl daemon-reload
systemctl enable laravoole
systemctl restart laravoole

配置成了开机启动,并且如果进程意外退出,系统会重新拉起。
手动重启可以使用 systemctl 或 service 命令。

CLI mode

Example:
Function phpinfo() has different output between cli and cgi.
But laravoole is running under CLI mode, so far I think avoiding these functions is the only way.

部分异常、错误未捕获,导致页面出现无法响应

laravoole v0.5.1,Laravel 5.1,Swoole 1.9.8,openresty 1.11.2.2

Laravoole\Base->handleRequest() 不严密。

约 157 行 finally $this->events->fire('laravoole.requested', [$illuminate_request, $illuminate_response]); 附近 以及 return $illuminate_response,如果遇到一些错误,不会存在 $illuminate_response变量。

问题复现:
storage/framework/views 设置无写入权限,并清空模板缓存。
访问需要view模板的页面,即产生无权限的日志,但是出现了意外情况没有捕获。页面无响应。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.