-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathrun.php
executable file
·30 lines (28 loc) · 1.05 KB
/
run.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
#!/usr/bin/php
<?php
@ob_end_clean();
ob_start();
use Garden\Cli\Cli;
$composerClassLoader = require "vendor/autoload.php";
define('APP_ROOT', __DIR__);
$cli = new Cli();
$cli->description('GraphJS Server')
->opt('conf:C', 'Config file.', false)
->opt('port:P', 'Port number to serve requests.', false, 'integer')
->opt('domain:D', 'CORS domain(s) to serve. Separate by semicolon, if multiple.', false)
->opt('heroku:H', 'Set "yes" if this is a Heroku installation', false);
$args = $cli->parse($argv, true);
$port = $args->getOpt(
'port',
(getenv('PORT') ? getenv('PORT') : 1338) // default
);
$configs = $args->getOpt('conf', "");
$cors = $args->getOpt('domain', "");
$heroku = ($args->getOpt('heroku', false) === "yes");
$server = new \GraphJS\Daemon($configs, $cors, $heroku);
$server->setPort($port);
ob_end_flush();
error_log(sprintf("Serving through port %s with the config file %s", (string) $port, $configs));
$max_upload_size = getenv('MAX_UPLOAD_SIZE') ?? "20M";
ini_set("upload_max_filesize", $max_upload_size);
$server->serve();