Skip to content

Commit

Permalink
fix: requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
takb committed Jul 27, 2023
1 parent 580204b commit 2a5ffb5
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 26 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ jobs:
run: |
mkdir $(pwd)/graphs $(pwd)/conf
sudo chown 1000:1000 $(pwd)/graphs $(pwd)/conf
docker run -it -d -p 8080:8080 --name ors-instance ${{ needs.prepare_environment.outputs.test_image_name }}
docker run -it -d -p 8080:8080 -v $(pwd)/graphs:/home/ors/ors-core/data/graphs -v $(pwd)/conf:/home/ors/ors-conf -e ORS_CONFIG_LOCATION=ors-conf/ors-config.yml --name ors-instance ${{ needs.prepare_environment.outputs.test_image_name }}
# Check for health to turn 200 after the graphs are build and spring-boot completely started
./.github/utils/url_check.sh 127.0.0.1 8080 /ors/v2/health 200 ${{ env.HEALTH_WAIT_TIME }}
# Check for correct preflight settings to avoid CORS issues with ORIGIN wildcard from the example config
Expand All @@ -122,7 +122,7 @@ jobs:
# Restart the container to apply the config changes
docker stop ors-instance
docker container prune -f
docker run -it -d -p 8080:8080 -e ORS_CORS_ALLOWED_ORIGINS=https://example.org --name ors-instance ${{ needs.prepare_environment.outputs.test_image_name }}
docker run -it -d -p 8080:8080 -v $(pwd)/graphs:/home/ors/ors-core/data/graphs -v $(pwd)/conf:/home/ors/ors-conf -e ORS_CORS_ALLOWED_ORIGINS=https://example.org --name ors-instance ${{ needs.prepare_environment.outputs.test_image_name }}
# Request preflight with https://example.com and https://example.org to see if it gets applied correctly
./.github/utils/cors_check.sh 127.0.0.1 8080 /ors/v2/isochrones/geojson "https://example.org" 200 50
# It should fail with http code 403 for https://example.com since the Origin is not covered.
Expand Down
7 changes: 3 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,8 @@ ENV LANG='en_US' LANGUAGE='en_US' LC_ALL='en_US'
RUN apk add --no-cache bash=~'5' openssl=~'3' && \
addgroup -g ${GID} ors && \
adduser -D -h ${BASE_FOLDER} -u ${UID} -G ors ors && \
mkdir -p ${BASE_FOLDER}/logs ${BASE_FOLDER}/graphs ${BASE_FOLDER}/elevation_cache ${BASE_FOLDER}/conf ${BASE_FOLDER}/data ${BASE_FOLDER}/tomcat/logs&& \
chown -R ors ${BASE_FOLDER}/logs ${BASE_FOLDER}/graphs ${BASE_FOLDER}/elevation_cache ${BASE_FOLDER}/conf ${BASE_FOLDER}/data ${BASE_FOLDER}/tomcat ${BASE_FOLDER}/tomcat/logs

mkdir -p ${BASE_FOLDER}/ors-core/logs ${BASE_FOLDER}/ors-conf ${BASE_FOLDER}/tomcat/logs && \
chown -R ors ${BASE_FOLDER}/tomcat ${BASE_FOLDER}/ors-core/logs ${BASE_FOLDER}/ors-conf ${BASE_FOLDER}/tomcat/logs
WORKDIR ${BASE_FOLDER}

# Copy over the needed bits and pieces from the other stages.
Expand All @@ -81,7 +80,7 @@ COPY --chown=ors:ors ./$OSM_FILE ${BASE_FOLDER}/tmp/osm_file.pbf
USER ${UID}:${GID}

ENV BUILD_GRAPHS="False"
ENV ORS_CONFIG_LOCATION=conf/ors-config.yml
ENV ORS_CONFIG_LOCATION=ors-conf/ors-config.yml

# Start the container
ENTRYPOINT ["/home/ors/docker-entrypoint.sh"]
Expand Down
8 changes: 4 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ services:
# args:
# OSM_FILE: ./ors-api/src/test/files/heidelberg.osm.gz
volumes:
- ./docker/graphs:/home/ors/graphs
- ./docker/elevation_cache:/home/ors/elevation_cache
- ./docker/graphs:/home/ors/ors-core/data/graphs
- ./docker/elevation_cache:/home/ors/ors-core/data/elevation_cache
- ./docker/logs/ors:/home/ors/logs
- ./docker/logs/tomcat:/home/ors/tomcat/logs
- ./docker/conf:/home/ors/conf
- ./docker/data:/home/ors/data
- ./docker/conf:/home/ors/ors-conf
- ./docker/data:/home/ors/ors-core/data
environment:
- BUILD_GRAPHS=False # Forces the container to rebuild the graphs, e.g. when PBF is changed
- "JAVA_OPTS=-Djava.awt.headless=true -server -XX:TargetSurvivorRatio=75 -XX:SurvivorRatio=64 -XX:MaxTenuringThreshold=3 -XX:+UseG1GC -XX:+ScavengeBeforeFullGC -XX:ParallelGCThreads=4 -Xms1g -Xmx2g"
Expand Down
10 changes: 5 additions & 5 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fi

ors_base=${1}
catalina_base=${ors_base}/tomcat
graphs=${ors_base}/graphs
graphs=${ors_base}/ors-core/data/graphs

echo "ORS Path: ${ors_base}"
echo "Catalina Path: ${catalina_base}"
Expand All @@ -38,14 +38,14 @@ if [ "${BUILD_GRAPHS}" = "True" ]; then
fi

echo "### openrouteservice configuration ###"
if [ ! -f "${ors_base}/conf/ors-config.yml" ]; then
if [ ! -f "${ors_base}/ors-conf/ors-config.yml" ]; then
echo "Copy ors-config.yml"
cp -f "${ors_base}/tmp/ors-config.yml" "${ors_base}/conf/ors-config.yml"
cp -f "${ors_base}/tmp/ors-config.yml" "${ors_base}/ors-conf/ors-config.yml"
fi

if [ ! -f "${ors_base}/data/osm_file.pbf" ]; then
if [ ! -f "${ors_base}/ors-core/data/osm_file.pbf" ]; then
echo "Copy osm_file.pbf"
cp -f "${ors_base}/tmp/osm_file.pbf" "${ors_base}/data/osm_file.pbf"
cp -f "${ors_base}/tmp/osm_file.pbf" "${ors_base}/ors-core/data/osm_file.pbf"
fi

# so docker can stop the process gracefully
Expand Down
6 changes: 3 additions & 3 deletions ors-api/ors-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ ors:
engine:
### use the following line for development setup using test OSM file for Heidelberg
# source_file: ./src/test/files/heidelberg.osm.gz
source_file: ./data/osm_file.pbf
graphs_root_path: ./graphs
source_file: ./ors-core/data/osm_file.pbf
graphs_root_path: ./ors-core/data/graphs
elevation:
cache_path: ./elevation_cache
cache_path: ./ors-core/data/elevation_cache

profiles:
car:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@

import jakarta.servlet.ServletContextEvent;
import jakarta.servlet.ServletContextListener;
import org.heigit.ors.util.StringUtility;

import static org.heigit.ors.api.ORSEnvironmentPostProcessor.ORS_CONFIG_LOCATION_ENV;
import static org.heigit.ors.api.ORSEnvironmentPostProcessor.ORS_CONFIG_LOCATION_PROPERTY;

public class ORSInitContextListener implements ServletContextListener {
private static final Logger LOGGER = Logger.getLogger(ORSInitContextListener.class);
Expand All @@ -42,6 +46,14 @@ public ORSInitContextListener(EngineProperties engineProperties) {

@Override
public void contextInitialized(ServletContextEvent contextEvent) {
if (LOGGER.isDebugEnabled()) {
if (!StringUtility.isNullOrEmpty(System.getenv(ORS_CONFIG_LOCATION_ENV))) {
LOGGER.debug("Configuration loaded by ENV, location: " + System.getenv(ORS_CONFIG_LOCATION_ENV));
}
if (!StringUtility.isNullOrEmpty(System.getProperty(ORS_CONFIG_LOCATION_PROPERTY))) {
LOGGER.debug("Configuration loaded by ARG, location: " + System.getProperty(ORS_CONFIG_LOCATION_PROPERTY));
}
}
final EngineConfig config = EngineConfig.EngineConfigBuilder.init()
.setInitializationThreads(engineProperties.getInitThreads())
.setPreparationMode(engineProperties.isPreparationMode())
Expand Down
2 changes: 1 addition & 1 deletion ors-api/src/main/resources/log4j.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ log4j.rootLogger=DEBUG, A1
# A1 is set to be a ConsoleAppender.
log4j.appender.A1=org.apache.log4j.ConsoleAppender
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
#log4j.appender.A1.layout.ConversionPattern=%d{dd MMM HH:mm:ss} %p [%c{2}] - %m%n
log4j.appender.A1.layout.ConversionPattern=%d{dd MMM HH:mm:ss} %p [%c{2}] - %m%n

log4j.logger.org.heigit=WARN
log4j.logger.org.apache=WARN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import org.heigit.ors.routing.RoutingProfileManagerStatus;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.extension.BeforeAllCallback;
import org.junit.jupiter.api.extension.BeforeEachCallback;
import org.junit.jupiter.api.extension.ExtensionContext;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.util.FileSystemUtils;
Expand All @@ -14,7 +13,7 @@
import java.nio.file.Paths;

@Order(Integer.MIN_VALUE) // Run before even spring context has been built
public class InitializeGraphsOnce implements BeforeAllCallback, BeforeEachCallback {
public class InitializeGraphsOnce implements BeforeAllCallback {

private static final Logger LOGGER = Logger.getLogger(InitializeGraphsOnce.class.getName());

Expand All @@ -37,10 +36,6 @@ public void beforeAll(ExtensionContext extensionContext) {
}
}

@Override
public void beforeEach(ExtensionContext context) {
}

private synchronized static void deleteGraphsFolderOncePerTestRun(ExtensionContext.Store store) {
boolean graphsFolderAlreadyDeleted = store.getOrDefault(GRAPHS_FOLDER_DELETED, Boolean.class, Boolean.FALSE);
boolean ciPropertySet = System.getProperty("CI") != null && System.getProperty("CI").equalsIgnoreCase("true");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public void initialize(EngineConfig config) {
}
}

LOGGER.info("%d tasks submitted.".formatted(nTotalTasks));
LOGGER.info("%d profile configurations submitted as tasks.".formatted(nTotalTasks));

int nCompletedTasks = 0;
while (nCompletedTasks < nTotalTasks) {
Expand Down

0 comments on commit 2a5ffb5

Please sign in to comment.