SERVER: use the own hostname to set the chunk url

master
Martin Gerhardy 2020-05-01 14:37:43 +02:00
parent ca5ee0ccb8
commit e75397479d
5 changed files with 17 additions and 10 deletions

View File

@ -66,10 +66,7 @@ option(USE_CPPCHECK "Enable cppcheck" OFF)
option(USE_CLANG_TIDY "Enable Clang Tidy" OFF)
set(PKGDATADIR "" CACHE STRING "System directory to search for data files")
set(DB_PW "engine" CACHE STRING "The database password")
set(SERVER_DOMAIN "localdomain")
set(SERVER_HOST "localhost.${SERVER_DOMAIN}" CACHE STRING "Host where the server is running on")
set(SERVER_PORT "11337" CACHE STRING "Port where the server is listening on")
set(HTTP_SERVER_HOST "${SERVER_HOST}" CACHE STRING "Host where the http server is running on")
set(HTTP_SERVER_PORT "8080" CACHE STRING "Port where the http server is listening on")
set(DOCKER_REGISTRY "" CACHE STRING "Docker registry")

View File

@ -9,7 +9,6 @@
#define PROJECT_VERSION_MINOR "@PROJECT_VERSION_MINOR@"
#define PROJECT_VERSION_PATCH "@PROJECT_VERSION_PATCH@"
#define HTTP_SERVER_HOST "@HTTP_SERVER_HOST@"
#define HTTP_SERVER_PORT "@HTTP_SERVER_PORT@"
#define SERVER_HOST "@SERVER_HOST@"
#define SERVER_PORT "@SERVER_PORT@"

View File

@ -121,7 +121,7 @@ public:
static VarPtr getSafe(const core::String& name);
/**
* @return @c empty string if var with given name wasn't found, otherwise the value of the var
* @return empty string if var with given name wasn't found, otherwise the value of the var
*/
static core::String str(const core::String& name);

View File

@ -51,12 +51,23 @@ core::AppState Server::onConstruct() {
core::Var::get(cfg::ServerHost, "0.0.0.0");
core::Var::get(cfg::ServerMaxClients, "1024");
core::Var::get(cfg::ServerHttpPort, HTTP_SERVER_PORT, core::CV_REPLICATE);
core::Var::get(cfg::ServerChunkBaseUrl, "http://" HTTP_SERVER_HOST ":" HTTP_SERVER_PORT "/chunk", core::CV_REPLICATE);
core::Var::get(cfg::ServerSeed, "1", core::CV_REPLICATE);
core::Var::get(cfg::VoxelMeshSize, "16", core::CV_READONLY);
core::Var::get(cfg::DatabaseMinConnections, "2");
core::Var::get(cfg::DatabaseMaxConnections, "100");
const core::VarPtr& chunkUrl = core::Var::get(cfg::ServerChunkBaseUrl, "", core::CV_REPLICATE);
if (chunkUrl->strVal().empty()) {
char hostname[256];
size_t size = sizeof(hostname);
if (uv_os_gethostname(hostname, &size) == 0) {
const core::String& url = core::string::format("http://%s:" HTTP_SERVER_PORT "/chunk", hostname);
chunkUrl->setVal(url);
} else {
chunkUrl->setVal("http://localhost:" HTTP_SERVER_PORT "/chunk");
}
}
_serverLoop->construct();
return state;

View File

@ -8,11 +8,11 @@ spec:
issuerRef:
name: ca-issuer
kind: ClusterIssuer
commonName: @HTTP_SERVER_HOST@
commonName: server.domain.todo
organization:
- @SERVER_DOMAIN@
- domain.todo
dnsNames:
- @HTTP_SERVER_HOST@
- server.domain.todo
---
apiVersion: "networking.k8s.io/v1beta1"
kind: "Ingress"
@ -21,7 +21,7 @@ metadata:
name: "@PROJECT_NAME@"
spec:
rules:
- host: @HTTP_SERVER_HOST@
- host: server.domain.todo
http:
paths:
- path: /