Browse Source

feat: get `KMS_PORT` env

master
Dnomd343 2 years ago
parent
commit
8847259410
  1. 13
      kms.php
  2. 1
      nginx/kms.conf
  3. 9
      src/Basis.php

13
kms.php

@ -40,6 +40,10 @@ pcntl_signal(SIGINT, function() { // receive SIGINT signal
subExit($nginx['pidFile'], $phpFpm['pidFile'], $vlmcsd['pidFile']);
});
if (in_array('--debug', $argv)) { // enter debug mode
logging::$logLevel = logging::DEBUG;
}
$KMS_PORT = 1688; // kms expose port -> only in message output
if (sizeof(getopt('', ['port:'])) == 1) { // port option
$KMS_PORT = getopt('', ['port:'])['port'];
@ -47,11 +51,10 @@ if (sizeof(getopt('', ['port:'])) == 1) { // port option
$KMS_PORT = end($KMS_PORT);
}
}
if (in_array('--debug', $argv)) { // enter debug mode
logging::$logLevel = logging::DEBUG;
}
logging::debug('KMS Server Port -> ' . $KMS_PORT);
$php_env_file = fopen('/etc/nginx/kms_params', 'w');
fwrite($php_env_file, 'fastcgi_param KMS_PORT "' . $KMS_PORT . '";' . PHP_EOL);
fclose($php_env_file);
logging::info('Loading kms-server (' . $VERSION . ')');
new Process($nginx['command']);

1
nginx/kms.conf

@ -16,6 +16,7 @@ server {
if ($http_user_agent ~* (curl|wget)) {
set $query_param $query_param&cli=true;
}
include kms_params;
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param QUERY_STRING $query_param;

9
src/Basis.php

@ -65,11 +65,10 @@ function getHost(): string {
}
function getPort(): int {
// TODO: check env
echo 'KMS_PORT -> ' . getenv("KMS_PORT");
return 1688;
if (getenv("KMS_PORT") == null) {
return 1688; // default server port
}
return intval(getenv("KMS_PORT"));
}
function officeInfo(): array { // office dir and kms key for different version

Loading…
Cancel
Save