Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fork #405

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from
Draft

Fork #405

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 32 additions & 32 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,38 +15,38 @@ jobs:
- name: Check out the repo
uses: actions/checkout@v4

- name: Build and potentially push Docker image
uses: docker/build-push-action@v5
with:
context: .
# ensure latest base image is used
pull: true
push: false
tags: adaguc-server
- name: Run Trivy vulnerability scanner
uses: aquasecurity/[email protected]
with:
image-ref: 'adaguc-server'
format: 'table'
exit-code: '1'
ignore-unfixed: true
vuln-type: 'os,library'
trivyignores: .trivyignore
# severity: 'CRITICAL,HIGH'
docker-build-and-publish:
name: Build Docker image and potentially push to Docker Hub
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v4
# - name: Build and potentially push Docker image
# uses: docker/build-push-action@v5
# with:
# context: .
# # ensure latest base image is used
# pull: true
# push: false
# tags: adaguc-server
# - name: Run Trivy vulnerability scanner
# uses: aquasecurity/[email protected]
# with:
# image-ref: 'adaguc-server'
# format: 'table'
# exit-code: '1'
# ignore-unfixed: true
# vuln-type: 'os,library'
# trivyignores: .trivyignore
# # severity: 'CRITICAL,HIGH'
# docker-build-and-publish:
# name: Build Docker image and potentially push to Docker Hub
# runs-on: ubuntu-latest
# steps:
# - name: Check out the repo
# uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: 'arm64'
# - name: Set up QEMU
# uses: docker/setup-qemu-action@v3
# with:
# platforms: 'arm64'

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3

- name: Log in to Docker Hub
if: github.repository == 'KNMI/adaguc-server'
Expand All @@ -65,9 +65,9 @@ jobs:
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
platforms: linux/amd64
# ensure latest base image is used
pull: true
push: ${{ github.repository == 'KNMI/adaguc-server' }}
tags: ${{ steps.meta.outputs.tags }}
tags: ${{ steps.meta.outputs.tags }}-20240911T1446
labels: ${{ steps.meta.outputs.labels }}
1 change: 1 addition & 0 deletions Docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ services:
- "ADAGUC_DATA_DIR=/data/adaguc-data"
- "ADAGUC_DATASET_DIR=/data/adaguc-datasets"
- "ADAGUC_REDIS=redis://adaguc-redis:6379"
- "ADAGUC_FORK_SOCKET_PATH=adaguc.socket"
env_file:
- .env
restart: unless-stopped
Expand Down
2 changes: 1 addition & 1 deletion Docker/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ done

export ADAGUC_PATH=/adaguc/adaguc-server-master/ && \
export ADAGUC_TMP=/tmp && \
/adaguc/adaguc-server-master/bin/adagucserver --updatedb \
env -u ADAGUC_FORK_SOCKET_PATH /adaguc/adaguc-server-master/bin/adagucserver --updatedb \
--config /adaguc/adaguc-server-config.xml,baselayers.xml

if [ $? -ne 0 ]
Expand Down
11 changes: 11 additions & 0 deletions Docker/supervisord/adaguc-pgbouncer.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ stdout_logfile_maxbytes=0
redirect_stderr=true
command=/adaguc/start.sh

[program:adagucbin]
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
redirect_stderr=true
environment=
ADAGUC_FORK_SOCKET_PATH=1,
ADAGUC_PATH=/adaguc/adaguc-server-master/,
ADAGUC_TMP=/tmp,
ADAGUC_CONFIG=/adaguc/adaguc-server-master/python/lib/adaguc/adaguc-server-config-python-postgres.xml
command=/adaguc/adaguc-server-master/bin/adagucserver
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to discuss if it would be a good solution to start this executable once in the python code. The reasoning is that the python code has logic to calculate the environment variables like ADAGUC_ONLINERESOURCE and others.


[program:pgbouncer]
stdout_logfile=/dev/fd/2
stdout_logfile_maxbytes=0
Expand Down
11 changes: 11 additions & 0 deletions Docker/supervisord/adaguc.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@ nodaemon=true
logfile=/dev/null
logfile_maxbytes=0

[program:adagucbin]
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
redirect_stderr=true
environment=
ADAGUC_FORK_SOCKET_PATH=1,
ADAGUC_PATH=/adaguc/adaguc-server-master/,
ADAGUC_TMP=/tmp,
ADAGUC_CONFIG=/adaguc/adaguc-server-master/python/lib/adaguc/adaguc-server-config-python-postgres.xml
command=/adaguc/adaguc-server-master/bin/adagucserver

[program:adaguc]
stdout_logfile=/dev/fd/1
stdout_logfile_maxbytes=0
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,12 @@ ENV PYTHONPATH=${ADAGUC_PATH}/python/python_fastapi_server
# Build and test adaguc python support
WORKDIR /adaguc/adaguc-server-master/python/lib/
RUN python3 setup.py install
RUN bash -c "python3 /adaguc/adaguc-server-master/python/examples/runautowms/run.py && ls result.png"
# RUN bash -c "python3 /adaguc/adaguc-server-master/python/examples/runautowms/run.py && ls result.png"

WORKDIR /adaguc/adaguc-server-master

# This checks if the test stage has ran without issues.
COPY --from=test /adaguc/adaguc-server-master/testsdone.txt /adaguc/adaguc-server-master/testsdone.txt
# COPY --from=test /adaguc/adaguc-server-master/testsdone.txt /adaguc/adaguc-server-master/testsdone.txt

USER adaguc

Expand Down
3 changes: 3 additions & 0 deletions adagucserverEC/CImageDataWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2563,6 +2563,9 @@ int CImageDataWriter::end() {
resetErrors();

printf("%s", resultHTML.c_str());

fflush(stdout);
fflush(stderr);
} /*End of text html */

/* Text XML */
Expand Down
2 changes: 2 additions & 0 deletions adagucserverEC/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ add_library(
Types/ProjectionStore.h
Types/ProjectionStore.cpp
testadagucserver.cpp
fork_server.h
fork_server.cpp
)

target_include_directories(adagucserverEC PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${Cairo_INCLUDE_DIRS} ${FREETYPE_INCLUDE_DIRS} ${PostgreSQL_INCLUDE_DIRS} ${GDAL_INCLUDE_DIRS} ${PROJ_INCLUDE_DIR})
Expand Down
3 changes: 3 additions & 0 deletions adagucserverEC/CRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,9 @@ int CRequest::process_wms_getcap_request() {
printf("%s", XMLdocument.c_str());
}

fflush(stdout);
fflush(stderr);

return 0;
}

Expand Down
50 changes: 37 additions & 13 deletions adagucserverEC/adagucserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@
#include <getopt.h>

#include "ProjCache.h"
#include "fork_server.h"

#include <sys/socket.h>
#include <sys/un.h>
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include "adagucserver.h"
#include "Types/ProjectionStore.h"
#include "utils/UpdateLayerMetadata.h"
Expand Down Expand Up @@ -163,14 +170,14 @@ int runRequest() {
return request.runRequest();
}

int _main(int argc, char **argv, char **) {
int _main(int argc, char **argv, char **, bool is_forked) {

/* Initialize error functions */
seterrormode(EXCEPTIONS_PLAINTEXT);
setStatusCode(HTTP_STATUSCODE_200_OK);
setErrorFunction(serverLogFunctionCMDLine);
setWarningFunction(serverLogFunctionCMDLine);
setDebugFunction(serverLogFunctionCMDLine);
// setErrorFunction(serverLogFunctionCMDLine);
// setWarningFunction(serverLogFunctionCMDLine);
// setDebugFunction(serverLogFunctionCMDLine);

int opt;
int scanFlags = 0;
Expand Down Expand Up @@ -372,25 +379,25 @@ int _main(int argc, char **argv, char **) {
}

/* Process the OGC request */
setErrorFunction(serverErrorFunction);
setWarningFunction(serverWarningFunction);
setDebugFunction(serverDebugFunction);
// setErrorFunction(serverErrorFunction);
// setWarningFunction(serverWarningFunction);
// setDebugFunction(serverDebugFunction);

#ifdef MEASURETIME
// #ifdef MEASURETIME
StopWatch_Start();
#endif
// #endif

status = runRequest();
/* Display errors if any */
readyerror();
#ifdef MEASURETIME
// #ifdef MEASURETIME
StopWatch_Stop("Ready!!!");
#endif
// #endif

return getStatusCode();
}

int main(int argc, char **argv, char **envp) {
int run_adaguc_once(int argc, char **argv, char **envp, bool is_forked) {
/* Check if ADAGUC_LOGFILE is set */
const char *ADAGUC_LOGFILE = getenv("ADAGUC_LOGFILE");
if (ADAGUC_LOGFILE != NULL) {
Expand Down Expand Up @@ -437,7 +444,7 @@ int main(int argc, char **argv, char **envp) {
CDBDebug("ADAGUC_TMP environment variable is not set, setting to : [%s]", ADAGUC_TMP);
}

int status = _main(argc, argv, envp);
int status = _main(argc, argv, envp, is_forked);

/* Print the check report formatted as JSON. */
CReportWriter::writeJSONReportToFile();
Expand All @@ -457,6 +464,23 @@ int main(int argc, char **argv, char **envp) {
fclose(pLogDebugFile);
pLogDebugFile = NULL;
}
close(1);
close(2);

return status;
}

int main(int argc, char **argv, char **envp) {
// If these lines are commented out, the calls the /edr/collections/instances/<my-instance> fail to return data
// because the call to `request=getreferencetimes` does not contain useful output
setvbuf(stdout, NULL, _IONBF, 0); // turn off buffering
setvbuf(stderr, NULL, _IONBF, 0); // turn off buffering

const char *ADAGUC_FORK_SOCKET_PATH = getenv("ADAGUC_FORK_SOCKET_PATH");
if (ADAGUC_FORK_SOCKET_PATH != NULL) {
return run_as_fork_service(run_adaguc_once, argc, argv, envp);
} else {
// normal flow without unix socket server/fork
return run_adaguc_once(argc, argv, envp, false);
}
}
Loading