1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* RPC serving init |
4
|
|
|
* User: moyo |
5
|
|
|
* Date: 18/03/2018 |
6
|
|
|
* Time: 3:20 PM |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace Carno\HRPC\Components; |
10
|
|
|
|
11
|
|
|
use Carno\Console\Component; |
12
|
|
|
use Carno\Console\Contracts\Application; |
13
|
|
|
use Carno\Console\Contracts\Bootable; |
14
|
|
|
use Carno\Container\DI; |
15
|
|
|
use Carno\HRPC\Handlers\ExceptionDump; |
16
|
|
|
use Carno\HRPC\Handlers\RequestLogger; |
17
|
|
|
use Carno\HRPC\Handlers\ServerReplier; |
18
|
|
|
use Carno\HRPC\Handlers\ServerUnavailable; |
19
|
|
|
use Carno\HRPC\Handlers\ServerWrapper; |
20
|
|
|
use Carno\HRPC\Handlers\TrafficMonitor; |
21
|
|
|
use Carno\Monitor\Daemon; |
|
|
|
|
22
|
|
|
use Carno\RPC\Handlers\ServiceInvoker; |
23
|
|
|
use Carno\RPC\Options; |
24
|
|
|
use Carno\RPC\Server; |
25
|
|
|
use Carno\RPC\Service\Dispatcher; |
|
|
|
|
26
|
|
|
|
27
|
|
|
class Serving extends Component implements Bootable |
28
|
|
|
{ |
29
|
|
|
/** |
30
|
|
|
* @var array |
31
|
|
|
*/ |
32
|
|
|
protected $dependencies = [Dispatcher::class]; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @param Application $app |
36
|
|
|
*/ |
37
|
|
|
public function starting(Application $app) : void |
38
|
|
|
{ |
39
|
|
|
// assign global extensions manager of server |
40
|
|
|
Server::layers()->append( |
41
|
|
|
null, |
42
|
|
|
DI::object(ExceptionDump::class), |
43
|
|
|
DI::object(ServerReplier::class), |
44
|
|
|
DI::object(ServerWrapper::class), |
45
|
|
|
DI::object(RequestLogger::class), |
46
|
|
|
DI::object(ServiceInvoker::class, DI::get(Dispatcher::class), $options = new Options()) |
47
|
|
|
); |
48
|
|
|
|
49
|
|
|
// initial mark server "unavailable" |
50
|
|
|
Server::layers()->append(ServerWrapper::class, DI::object(ServerUnavailable::class)); |
51
|
|
|
|
52
|
|
|
$app->starting()->add(static function () use ($app, $options) { |
53
|
|
|
// add traffic monitor layer |
54
|
|
|
DI::has(Daemon::class) && Server::layers()->append( |
55
|
|
|
ServerWrapper::class, |
56
|
|
|
DI::object(TrafficMonitor::class) |
57
|
|
|
); |
58
|
|
|
// configurable options link |
59
|
|
|
$app->conf()->bind($options, ['rpc.serv.opts' => ['tt.exec' => 'ttExec']]); |
|
|
|
|
60
|
|
|
}); |
61
|
|
|
|
62
|
|
|
$app->starting()->done()->then(static function () { |
63
|
|
|
// mark server "available" when bootstrap done |
64
|
|
|
Server::layers()->remove(ServerUnavailable::class); |
65
|
|
|
}); |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths