Add .ini for configuration

This commit is contained in:
2020-06-20 19:04:10 +02:00
parent 906fe39e39
commit 744373e584
10 changed files with 92 additions and 63 deletions

13
bin/command Executable file
View File

@@ -0,0 +1,13 @@
#!/usr/bin/env php
<?php
array_shift($argv);
if (count($argv) === 0) {
print('command needs at least one argument' . PHP_EOL);
die(1);
}
$ini = parse_ini_file(__DIR__ . '/../config/config.ini', true)['command'];
$socket = new ZMQSocket(new ZMQContext, ZMQ::SOCKET_PUSH);
$socket->connect($ini['dsn']);
$socket->sendmulti($argv);

15
bin/query Executable file
View File

@@ -0,0 +1,15 @@
#!/usr/bin/env php
<?php
array_shift($argv);
if (count($argv) === 0) {
print('query needs at least one argument' . PHP_EOL);
die(1);
}
$ini = parse_ini_file(__DIR__ . '/../config/config.ini', true)['query'];
$socket = new ZMQSocket(new ZMQContext, ZMQ::SOCKET_REQ);
$socket->connect($ini['dsn']);
$socket->sendmulti($argv);
print(implode(PHP_EOL, $socket->recvMulti()));
print(PHP_EOL);

10
bin/server Executable file
View File

@@ -0,0 +1,10 @@
#!/usr/bin/env php
<?php
require_once __DIR__ . '/../src/FileServer.php';
$ini = parse_ini_file(__DIR__ . '/../config/config.ini', true)['server'];
$ini['storage_dir'] = str_replace('%ROOT_DIR%', realpath(__DIR__ . '/..'), $ini['storage_dir']);
$server = new FileServer(new ZMQContext, $ini['storage_dir'], $ini['command_dsn'], $ini['query_dsn']);
$server->run();