-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.php
39 lines (29 loc) · 1.05 KB
/
main.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
declare(strict_types=1);
namespace SocketLog;
use Dotenv\Dotenv;
use Phar;
use Symfony\Component\Console\Application;
use function define;
define('IN_PHAR', boolval(Phar::running(false)));
define('RUNNING_ROOT', realpath(getcwd()));
define('APP_ROOT', IN_PHAR ? Phar::running() : realpath(getcwd()));
define('RUNTIME_DIR', RUNNING_ROOT . DIRECTORY_SEPARATOR . 'runtime');
define('BUILD_DATETIME', '@compile-datetime@');
define('BUILD_VERSION', '@app-version@');
define('VERSION_TITLE', IN_PHAR ? \sprintf('%s', BUILD_VERSION) : '0.0.0');
require __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
if (\is_file(__DIR__ . DIRECTORY_SEPARATOR . '.env')) {
$dotenv = Dotenv::createMutable(__DIR__);
$dotenv->load();
Server::verifyEnv($dotenv);
}
if (!file_exists(RUNTIME_DIR)) {
@mkdir(RUNTIME_DIR, 0755, true);
}
$app = new Application('socket-log-server', VERSION_TITLE);
$command = new ServerCommand();
$app->add($command);
$app->setDefaultCommand($command->getName(), true);
$code = $app->run();
exit($code);