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']); 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 $KMS_PORT = 1688; // kms expose port -> only in message output
if (sizeof(getopt('', ['port:'])) == 1) { // port option if (sizeof(getopt('', ['port:'])) == 1) { // port option
$KMS_PORT = getopt('', ['port:'])['port']; $KMS_PORT = getopt('', ['port:'])['port'];
@ -47,11 +51,10 @@ if (sizeof(getopt('', ['port:'])) == 1) { // port option
$KMS_PORT = end($KMS_PORT); $KMS_PORT = end($KMS_PORT);
} }
} }
logging::debug('KMS Server Port -> ' . $KMS_PORT);
$php_env_file = fopen('/etc/nginx/kms_params', 'w');
if (in_array('--debug', $argv)) { // enter debug mode fwrite($php_env_file, 'fastcgi_param KMS_PORT "' . $KMS_PORT . '";' . PHP_EOL);
logging::$logLevel = logging::DEBUG; fclose($php_env_file);
}
logging::info('Loading kms-server (' . $VERSION . ')'); logging::info('Loading kms-server (' . $VERSION . ')');
new Process($nginx['command']); new Process($nginx['command']);

1
nginx/kms.conf

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

9
src/Basis.php

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

Loading…
Cancel
Save