22
33import com .cmclinnovations .stack .clients .core .EndpointNames ;
44import com .cmclinnovations .stack .clients .core .StackClient ;
5+ import com .cmclinnovations .stack .clients .core .StackHost ;
56import com .cmclinnovations .stack .clients .rdf4j .Rdf4jEndpointConfig ;
67import com .cmclinnovations .stack .services .config .ServiceConfig ;
78
89public class GrlcService extends ContainerService {
910
1011 public static final String TYPE = "grlc" ;
1112
13+ private static final String EXTERNAL_PORT_KEY = "EXTERNAL_PORT" ;
1214 private static final String GRLC_SERVER_NAME_KEY = "GRLC_SERVER_NAME" ;
1315 private static final String GRLC_SPARQL_ENDPOINT_KEY = "GRLC_SPARQL_ENDPOINT" ;
1416
@@ -19,13 +21,12 @@ public GrlcService(String stackName, ServiceConfig config) {
1921 @ Override
2022 protected void doPreStartUpConfiguration () {
2123
22- // String serverName = (StackClient.getStackHost()
23- // .getWithDefaults(null, "", "", "") + "rest/")
24- // .replaceAll("/+", "\\\\/");
25-
26- String serverName = StackClient .getStackHost ().getStringBuilder ()
27- .withName ()
28- .withPort ()
24+ StackHost stackHost = StackClient .getStackHost ();
25+ String serverName = stackHost .getStringBuilder ()
26+ // Assume running locally if name not set
27+ .withName ("localhost" )
28+ // Assume using Nginx external port if name not set, otherwise no port (80/443 assumed)
29+ .withPort (stackHost .getName ().isPresent () ? null : System .getenv (EXTERNAL_PORT_KEY ))
2930 .withPath ()
3031 .withExtraPath ("rest" )
3132 .build ()
0 commit comments