Configuration fixes, makefile tweaks
* The PHAR now gets tagged with version and buildtime * WebSocket support can now be disabled
This commit is contained in:
@ -2,7 +2,10 @@
|
||||
|
||||
namespace NoccyLabs\Mercureact;
|
||||
|
||||
use Monolog\Handler\StreamHandler;
|
||||
use Monolog\Logger;
|
||||
use NoccyLabs\Mercureact\Http\Server;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use React\EventLoop\Loop;
|
||||
use React\EventLoop\LoopInterface;
|
||||
use React\Socket\SocketServer;
|
||||
@ -15,19 +18,33 @@ class Daemon
|
||||
|
||||
private Server $server;
|
||||
|
||||
private LoggerInterface $logger;
|
||||
|
||||
public function __construct(Configuration $config, ?LoopInterface $loop=null)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->loop = $loop??Loop::get();
|
||||
$this->logger = $this->createLogger();
|
||||
}
|
||||
|
||||
private function createLogger(): Logger
|
||||
{
|
||||
$handlers = [
|
||||
new StreamHandler(STDOUT)
|
||||
];
|
||||
$logger = new Logger("main", $handlers);
|
||||
return $logger;
|
||||
}
|
||||
|
||||
public function start(): void
|
||||
{
|
||||
$this->server = new Server($this->config, $this->loop);
|
||||
$this->server = new Server($this->config, $this->logger, $this->loop);
|
||||
|
||||
$this->logger->info("NoccyLabs Mercureact Daemon v".MERCUREACT_VERSION);
|
||||
|
||||
$listenAddress = $this->config->getListenAddress();
|
||||
if (!$listenAddress) {
|
||||
fwrite(STDERR, "Warning: Empty listening address. You won't make it far.\n");
|
||||
$this->logger->warning("Empty listening address. You won't make it far.");
|
||||
return;
|
||||
}
|
||||
$socket = new SocketServer("tcp://".$listenAddress);
|
||||
|
Reference in New Issue
Block a user