Skip to content

Commit 0c9b87f

Browse files
authored
Fix issue where only one process caused a 1 second delay with concurrent GetMap requests (#24)
1 parent 0943bba commit 0c9b87f

3 files changed

Lines changed: 30 additions & 2 deletions

File tree

‎docker/runtime/usr/local/bin/start-server‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ echo "Starting with apache2"
44

55
# save the environment to be able to restore it in the FCGI daemon (used
66
# in /usr/local/bin/qgis_mapsev_wrapper) for the startup code.
7-
${GET_ENV} | sed -e 's/^\([^=]*\)=.*/PassEnv \1/' > /tmp/pass-env
7+
# hide any PassEnv variable _ was undefined warnings
8+
${GET_ENV} | grep -v '^_=' | sed -e 's/^\([^=]*\)=.*/PassEnv \1/' > /tmp/pass-env
89

910
# Save the environment to be able to restore it in the FCGI daemon (used in /usr/local/bin/mapserv_wrapper)
1011
${GET_ENV} | sed -e 's/.\+/export "\0"/' > /tmp/init_env

‎workshop/exercises/docker-compose.yml‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# Authors: Seth Girvin <sethg@geoggraphika.co.uk>
44
#
5-
# Copyright (c) 2024 Seth Girvin
5+
# Copyright (c) 2026 Seth Girvin
66
#
77
# Permission is hereby granted, free of charge, to any person
88
# obtaining a copy of this software and associated documentation
@@ -35,6 +35,9 @@ services:
3535
- 7000:8080
3636
environment:
3737
MAPSERVER_CONFIG_FILE: "/etc/mapserver/mapserver.conf"
38+
MIN_PROCESSES: 2
39+
IDLE_TIMEOUT: 3600 # 1 hour
40+
command: ["bash", "/scripts/start-with-warmup.sh"]
3841
volumes:
3942
- ./scripts:/scripts:z
4043
- ./mapfiles:/etc/mapserver:z
@@ -49,6 +52,8 @@ services:
4952
working_dir: /home/node/app
5053
volumes:
5154
- ./app:/home/node/app:z
55+
# Used for the GeoStyler demo
56+
- ./mapfiles/includes:/home/node/app/public/includes:ro,z-
5257
networks:
5358
- mynetwork
5459
command: >
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
# Start MapServer with several FastCGI processes already running.
3+
#
4+
# mod_fcgid only starts a new MapServer process without delay when none
5+
# is busy. Otherwise a request waits 1 second for a busy process to
6+
# become free, so short concurrent requests (e.g. GetStyles + GetMap)
7+
# are slow. Sending MIN_PROCESSES requests at once, right after start-up,
8+
# starts that many processes; FcgidMinProcessesPerClass keeps them alive.
9+
(
10+
sleep 3
11+
for _ in $(seq "${MIN_PROCESSES:-2}"); do
12+
(
13+
exec 3<>/dev/tcp/127.0.0.1/8080 \
14+
&& printf 'GET / HTTP/1.0\r\nHost: localhost\r\n\r\n' >&3 \
15+
&& cat <&3 >/dev/null
16+
) &
17+
done
18+
wait
19+
) &
20+
21+
# Continue with the image's normal start-up (Apache becomes PID 1)
22+
exec /usr/local/bin/start-server

0 commit comments

Comments
 (0)