Server not loading when 'HotCodeReload' is enabled
MassiCav opened this issue · comments
Bug Report
Q | A |
---|---|
PHP | 7.4.5 |
Swoole | 4.5.1 |
Summary
When starting, within a Docker container, a Mezzio based project according to the 'mezzio-swoole' documentation the Swoole server cannot start.
Current behavior
With a 'mezzio-swoole' configuration like the following:
<?php
declare(strict_types=1);
use Laminas\ServiceManager\Factory\InvokableFactory;
use Mezzio\Swoole\HotCodeReload\FileWatcher\InotifyFileWatcher;
use Psr\Log\LoggerInterface;
use \App\Swoole\Log\LoggerFactory;
return [
'dependencies' => [
'factories' => [
LoggerInterface::class => LoggerFactory::class,
//InotifyFileWatcher::class => InvokableFactory::class
],
'delegators' => [
\Swoole\Http\Server::class => [
\App\Swoole\Task\TaskControllerDelegator::class
],
],
],
'mezzio-swoole' => [
'enable_coroutine' => true,
'hot-code-reload' => [
'enable' => true,
'interval' => 500,
],
'swoole-http-server' => [
'host' => '*',
'port' => 9501,
'process-name' => 'mezzio',
'mode' => SWOOLE_PROCESS,
'options' => [
'worker_num' => 8,
'task_worker_num' => 4,
'task_enable_coroutine' => true
]
]
]
];
a ServiceManager related error is generated on server start:
In ServiceManager.php line 688:
Unable to resolve service "Mezzio\Swoole\HotCodeReload\FileWatcher\InotifyF
ileWatcher" to a factory; are you certain you provided it during configurat
ion?
How to reproduce
Follow 'mezzio-swoole' installation instruction, enable 'hot-code-reload'.
Reason for the issue
The module's 'ConfigProvider' specifies an 'alias' for related to the failing class (specified in above error) but the actual factory for that class is not defined in the dependencies manager.
Using the 'Laminas Service Manager' the solution is as easy as adding 'InotifyFileWatcher::class => InvokableFactory::class' in the 'factories' configuration.
Expected behavior
The Swoole server starts correctly as configured.