Skip to content

Commit

Permalink
Make fork server work in docker
Browse files Browse the repository at this point in the history
  • Loading branch information
mgrunbauer committed Sep 4, 2024
1 parent 549e6d1 commit 1d96bc1
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 13 deletions.
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=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: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=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
15 changes: 7 additions & 8 deletions adagucserverEC/adagucserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

#include <sys/socket.h>
#include <sys/un.h>
#include <stdio.h>

DEF_ERRORMAIN();

Expand Down Expand Up @@ -200,9 +201,9 @@ int _main(int argc, char **argv, char **) {
/* 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 @@ -378,9 +379,9 @@ 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
StopWatch_Start();
Expand Down Expand Up @@ -479,8 +480,6 @@ void handle_client(int client_socket, int argc, char **argv, char **envp) {
int data_recv = recv(client_socket, recv_buf, recv_buf_len, 0);
if (data_recv > 0) {
if (strncmp(recv_buf, cmd_query, strlen(cmd_query)) == 0) {
printf("@@@ creating image in child?");
fflush(stdout);
dup2(client_socket, STDOUT_FILENO);
// dup2(client_socket, STDERR_FILENO);

Expand Down
4 changes: 2 additions & 2 deletions compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ function clean {

function build {

# clean
clean
cd $CURRENTDIR/bin
cmake .. && cmake --build . --parallel 8
cmake .. && cmake --build . --parallel 4

if [ -f adagucserver ]
then
Expand Down
2 changes: 1 addition & 1 deletion python/lib/adaguc/CGIRunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async def run(self, cmds, url, output, env=[], path=None, isCGI=True, timeout=30
process_output = ""

client = socket.socket(socket.AF_UNIX)
client.connect("/tmp/adaguc.socke")
client.connect("/tmp/adaguc.socket")
client.send(f"QUERY_STRING={url}".encode())

process_output = bytearray()
Expand Down

0 comments on commit 1d96bc1

Please sign in to comment.