Skip to content

Commit 1d1a047

Browse files
committed
Merge branch 'release/2.11.0'
2 parents 665ed4e + f9c69c9 commit 1d1a047

8 files changed

Lines changed: 162 additions & 19 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Release Notes
22

3+
### Release 2.11.0 (2026-05-14)
4+
- Add Docker environment variables for full-rebuild data move configuration
5+
- Change `--no-move` to read protected event IDs from a text file
6+
- Exclude Reported Intensity directories during first-boot event processing
7+
38
### Release 2.10.0 (2026-05-14)
49
- Add `process_events.sh` options to move old realtime event directories to `data_storage`
510
- Add `--no-move` protection list for event directories that must remain in `data`

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ COPY disclaimer*.md /usr/share/nginx/html/
2424
COPY contributors*.md /usr/share/nginx/html/
2525
COPY scientific-background*.md /usr/share/nginx/html/
2626
COPY productsListToProcess.json /usr/share/nginx/html/
27+
COPY EVENTID_DO_NOT_MOVE.txt /usr/share/nginx/html/
2728
COPY css/ /usr/share/nginx/html/css/
2829
COPY js/ /usr/share/nginx/html/js/
2930
COPY images/ /usr/share/nginx/html/images/

EVENTID_DO_NOT_MOVE.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Event IDs that must remain in data/ when DATA_MOVE_DAYS is enabled.
2+
# Add one event ID per line. Empty lines and lines starting with "#" are ignored.

README.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,26 @@ docker run -d -p 8080:80 \
7777

7878
When `PROCESS_ALL_DATA_FIRST_TIME=true` is set, the container will process events at startup before starting the Nginx server. It processes recent events from the realtime data directory first, then starts a full rebuild in the background; the full rebuild also includes `data_storage` when mounted.
7979

80+
**Run with automatic old-event moving enabled:**
81+
```bash
82+
docker run -d -p 8080:80 \
83+
-v $(pwd)/data:/usr/share/nginx/html/data:rw \
84+
-v $(pwd)/data_storage:/usr/share/nginx/html/data_storage:rw \
85+
-v $(pwd)/EVENTID_DO_NOT_MOVE.txt:/usr/share/nginx/html/EVENTID_DO_NOT_MOVE.txt:rw \
86+
--name shakemap4-web__container \
87+
-e PROCESS_ALL_DATA_FIRST_TIME=true \
88+
-e DATA_MOVE_DAYS=100 \
89+
-e DATA_MOVE_NO_MOVE_IDS=/usr/share/nginx/html/EVENTID_DO_NOT_MOVE.txt \
90+
ingv/shakemap4-web
91+
```
92+
93+
`DATA_MOVE_DAYS` is applied only to full rebuilds: the daily cron full rebuild
94+
and the second startup pass triggered by `PROCESS_ALL_DATA_FIRST_TIME=true`.
95+
Incremental runs (`-l`) never move data. `DATA_MOVE_NO_MOVE_IDS` must be an
96+
absolute path inside the container to a readable text file with one protected
97+
event ID per line. The file can be edited while the container is running; the
98+
next full rebuild reads the updated contents.
99+
80100
**Run with a specific environment profile (e.g. EU):**
81101
```bash
82102
docker run -d -p 8080:80 \
@@ -93,6 +113,8 @@ docker run -d -p 8080:80 \
93113
| `ENABLE_CRONTAB` | Enable automated event processing via cron | `false` | `true` |
94114
| `PROCESS_ALL_DATA_FIRST_TIME` | Process all events at container startup | `false` | `true` |
95115
| `SHAKEMAP_ENV` | Environment profile to load (`ingv`, `eu`, or custom) | `ingv` | `eu` |
116+
| `DATA_MOVE_DAYS` | Move realtime event directories older than this many days during full rebuilds | unset | `100` |
117+
| `DATA_MOVE_NO_MOVE_IDS` | Absolute container path to a file with event IDs that must not be moved | unset | `/usr/share/nginx/html/EVENTID_DO_NOT_MOVE.txt` |
96118

97119
**Notes:**
98120
- All environment variables are optional. If not set, the INGV defaults from `js/config-base.js` are used.
@@ -161,9 +183,11 @@ the destination already exists in `data_storage/`, it is overwritten.
161183

162184
Protect selected event IDs from moving with `--no-move`:
163185
```bash
164-
./process_events.sh --data-realtime-dir data/ --data-storage-dir data_storage/ --move-days 100 --no-move 432423,4342342,4342343 --exclude-dir-end _ri
186+
./process_events.sh --data-realtime-dir data/ --data-storage-dir data_storage/ --move-days 100 --no-move EVENTID_DO_NOT_MOVE.txt --exclude-dir-end _ri
165187
```
166-
Each protected ID also protects its matching `<eventid>_ri` directory.
188+
The `--no-move` file must contain one event ID per line. Empty lines and lines
189+
starting with `#` are ignored. Each protected ID also protects its matching
190+
`<eventid>_ri` directory.
167191

168192
When `--move-days` is used, both `data/` and `data_storage/` must be mounted
169193
read-write; the read-only Docker volume examples are suitable for serving and

docker-entrypoint.sh

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,60 @@ echo ""
1616
PROCESS_EVENTS_SCRIPT="/usr/share/nginx/html/process_events.sh"
1717
REALTIME_DATA_DIR="/usr/share/nginx/html/data"
1818
STORAGE_DATA_DIR="/usr/share/nginx/html/data_storage"
19+
DATA_MOVE_DAYS="${DATA_MOVE_DAYS:-}"
20+
DATA_MOVE_NO_MOVE_IDS="${DATA_MOVE_NO_MOVE_IDS:-}"
21+
22+
validate_data_move_config() {
23+
if [ -n "$DATA_MOVE_NO_MOVE_IDS" ] && [ -z "$DATA_MOVE_DAYS" ]; then
24+
echo "ERROR: DATA_MOVE_NO_MOVE_IDS requires DATA_MOVE_DAYS" >&2
25+
exit 1
26+
fi
27+
28+
if [ -z "$DATA_MOVE_DAYS" ]; then
29+
return 0
30+
fi
31+
32+
if ! [[ "$DATA_MOVE_DAYS" =~ ^[0-9]+$ ]] || [ "$DATA_MOVE_DAYS" -le 0 ]; then
33+
echo "ERROR: DATA_MOVE_DAYS must be a positive integer, got: $DATA_MOVE_DAYS" >&2
34+
exit 1
35+
fi
36+
37+
if [ ! -d "$STORAGE_DATA_DIR" ]; then
38+
echo "ERROR: DATA_MOVE_DAYS requires storage directory: $STORAGE_DATA_DIR" >&2
39+
exit 1
40+
fi
41+
42+
if [ -n "$DATA_MOVE_NO_MOVE_IDS" ]; then
43+
if [[ "$DATA_MOVE_NO_MOVE_IDS" != /* ]]; then
44+
echo "ERROR: DATA_MOVE_NO_MOVE_IDS must be an absolute path inside the container: $DATA_MOVE_NO_MOVE_IDS" >&2
45+
exit 1
46+
fi
47+
48+
if [ ! -f "$DATA_MOVE_NO_MOVE_IDS" ]; then
49+
echo "ERROR: DATA_MOVE_NO_MOVE_IDS file does not exist: $DATA_MOVE_NO_MOVE_IDS" >&2
50+
exit 1
51+
fi
52+
53+
if [ ! -r "$DATA_MOVE_NO_MOVE_IDS" ]; then
54+
echo "ERROR: DATA_MOVE_NO_MOVE_IDS file is not readable: $DATA_MOVE_NO_MOVE_IDS" >&2
55+
exit 1
56+
fi
57+
fi
58+
}
59+
60+
append_move_command_args() {
61+
local cmd=$1
62+
63+
if [ -n "$DATA_MOVE_DAYS" ]; then
64+
cmd="$cmd --move-days $DATA_MOVE_DAYS"
65+
66+
if [ -n "$DATA_MOVE_NO_MOVE_IDS" ]; then
67+
cmd="$cmd --no-move $DATA_MOVE_NO_MOVE_IDS"
68+
fi
69+
fi
70+
71+
printf '%s' "$cmd"
72+
}
1973

2074
get_full_rebuild_args() {
2175
local args=("--data-realtime-dir" "$REALTIME_DATA_DIR")
@@ -24,6 +78,14 @@ get_full_rebuild_args() {
2478
args+=("--data-storage-dir" "$STORAGE_DATA_DIR")
2579
fi
2680

81+
if [ -n "$DATA_MOVE_DAYS" ]; then
82+
args+=("--move-days" "$DATA_MOVE_DAYS")
83+
84+
if [ -n "$DATA_MOVE_NO_MOVE_IDS" ]; then
85+
args+=("--no-move" "$DATA_MOVE_NO_MOVE_IDS")
86+
fi
87+
fi
88+
2789
printf '%s\n' "${args[@]}"
2890
}
2991

@@ -34,9 +96,23 @@ get_full_rebuild_command() {
3496
cmd="$cmd --data-storage-dir $STORAGE_DATA_DIR"
3597
fi
3698

99+
cmd=$(append_move_command_args "$cmd")
100+
37101
printf '%s' "$cmd"
38102
}
39103

104+
validate_data_move_config
105+
106+
if [ -n "$DATA_MOVE_DAYS" ]; then
107+
echo "DATA_MOVE_DAYS is set to $DATA_MOVE_DAYS. Full rebuilds will move older events to storage."
108+
if [ -n "$DATA_MOVE_NO_MOVE_IDS" ]; then
109+
echo "DATA_MOVE_NO_MOVE_IDS is set to $DATA_MOVE_NO_MOVE_IDS."
110+
fi
111+
else
112+
echo "DATA_MOVE_DAYS is not set. Data move will not run."
113+
fi
114+
echo ""
115+
40116
# --- Cron setup for periodic event reprocessing ---
41117
if [ "$ENABLE_CRONTAB" = "true" ]; then
42118
echo "ENABLE_CRONTAB is set to true. Starting cron service..."
@@ -86,8 +162,9 @@ if [ "$PROCESS_ALL_DATA_FIRST_TIME" = "true" ]; then
86162
# so that events.json is available quickly and the portal is usable right away.
87163
# The second run rebuilds the full dataset in the background without blocking
88164
# nginx startup — it may take a long time on large data directories.
89-
"$PROCESS_EVENTS_SCRIPT" --data-realtime-dir "$REALTIME_DATA_DIR" -l 20
165+
"$PROCESS_EVENTS_SCRIPT" --data-realtime-dir "$REALTIME_DATA_DIR" -l 20 -x _ri
90166
mapfile -t FULL_REBUILD_ARGS < <(get_full_rebuild_args)
167+
FULL_REBUILD_ARGS+=("-x" "_ri")
91168
"$PROCESS_EVENTS_SCRIPT" "${FULL_REBUILD_ARGS[@]}" &
92169

93170
echo "All data processed."

js/config-base.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const ShakeMap = {
1919
};
2020

2121
const config = {
22-
version: "v2.10.0",
22+
version: "v2.11.0",
2323
githubLink: "https://github.com/INGV/shakemap4-web",
2424
disclaimerPage: './disclaimer-ingv.md',
2525
contributorsPage: './contributors-ingv.md',

process_events.sh

Lines changed: 48 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ echo_date() {
1818
# Function to display usage/help
1919
usage() {
2020
cat <<EOF
21-
Usage: $(basename "$0") -d DATA_DIR [-k DATA_STORAGE_DIR] [-m DAYS [-n IDS]] [-e EVENT_ID | -l LAST_N_EVENTS] [-x SUFFIX] [-h]
21+
Usage: $(basename "$0") -d DATA_DIR [-k DATA_STORAGE_DIR] [-m DAYS [-n FILE]] [-e EVENT_ID | -l LAST_N_EVENTS] [-x SUFFIX] [-h]
2222
2323
Process ShakeMap event data and generate events.json.
2424
@@ -37,9 +37,9 @@ Options:
3737
The event OriginTime is read directly from
3838
current/event.xml. Requires -d and -k
3939
--move-days DAYS Long alias for -m
40-
-n IDS Comma-separated event IDs that must never be
41-
moved when -m is used. Example: 432423,4342342
42-
--no-move IDS Long alias for -n
40+
-n FILE Path to a text file with event IDs that must never
41+
be moved when -m is used, one event ID per line
42+
--no-move FILE Long alias for -n
4343
-e EVENT_ID Process a single event by its ID. Performs an
4444
incremental update: adds or updates the event in
4545
events.json while preserving all other events
@@ -64,7 +64,8 @@ Examples:
6464
$(basename "$0") -d data/ -l 5 Process last 5 modified realtime events
6565
$(basename "$0") -d data/ -k data_storage/ -x _ri Full rebuild excluding dirs ending with "_ri"
6666
$(basename "$0") -d data/ -k data_storage/ -m 100 -x _ri Move events older than 100 days, then full rebuild
67-
$(basename "$0") -d data/ -k data_storage/ -m 100 -n 1,2,3 Move old events except listed IDs, then full rebuild
67+
$(basename "$0") -d data/ -k data_storage/ -m 100 -n EVENTID_DO_NOT_MOVE.txt
68+
Move old events except IDs listed in the file
6869
$(basename "$0") -d data/ --exclude-dir-end _ri Same exclusion, using long option
6970
$(basename "$0") -h Show this help
7071
EOF
@@ -175,7 +176,7 @@ SINGLE_EVENT_ID=""
175176
LAST_EVENTS=""
176177
EXCLUDE_DIR_END=""
177178
MOVE_DAYS=""
178-
NO_MOVE_IDS_CSV=""
179+
NO_MOVE_IDS_FILE=""
179180
NO_MOVE_IDS=()
180181
# Array to track events with time parsing issues
181182
EVENTS_WITH_TIME_PARSING=()
@@ -223,11 +224,11 @@ while [ $# -gt 0 ]; do
223224
shift
224225
;;
225226
--no-move)
226-
NO_MOVE_IDS_CSV="$2"
227+
NO_MOVE_IDS_FILE="$2"
227228
shift 2
228229
;;
229230
--no-move=*)
230-
NO_MOVE_IDS_CSV="${1#*=}"
231+
NO_MOVE_IDS_FILE="${1#*=}"
231232
shift
232233
;;
233234
*)
@@ -247,7 +248,7 @@ while getopts "d:e:l:x:k:m:n:h" opt; do
247248
;;
248249
m) MOVE_DAYS="$OPTARG"
249250
;;
250-
n) NO_MOVE_IDS_CSV="$OPTARG"
251+
n) NO_MOVE_IDS_FILE="$OPTARG"
251252
;;
252253
e) SINGLE_EVENT_ID="$OPTARG"
253254
;;
@@ -302,7 +303,7 @@ if [ -n "$MOVE_DAYS" ]; then
302303
fi
303304
fi
304305

305-
if [ -n "$NO_MOVE_IDS_CSV" ] && [ -z "$MOVE_DAYS" ]; then
306+
if [ -n "$NO_MOVE_IDS_FILE" ] && [ -z "$MOVE_DAYS" ]; then
306307
echo "Error: -n/--no-move is valid only when -m/--move-days is used" >&2
307308
echo "" >&2
308309
usage >&2
@@ -342,6 +343,18 @@ if [ -n "$MOVE_DAYS" ]; then
342343
fi
343344
fi
344345

346+
if [ -n "$NO_MOVE_IDS_FILE" ]; then
347+
if [ ! -f "$NO_MOVE_IDS_FILE" ]; then
348+
echo "Error: -n/--no-move file does not exist or is not a regular file: $NO_MOVE_IDS_FILE" >&2
349+
exit 1
350+
fi
351+
352+
if [ ! -r "$NO_MOVE_IDS_FILE" ]; then
353+
echo "Error: -n/--no-move file is not readable: $NO_MOVE_IDS_FILE" >&2
354+
exit 1
355+
fi
356+
fi
357+
345358
# Validate -l is a positive integer
346359
if [ -n "$LAST_EVENTS" ]; then
347360
if ! [[ "$LAST_EVENTS" =~ ^[0-9]+$ ]] || [ "$LAST_EVENTS" -le 0 ]; then
@@ -350,10 +363,6 @@ if [ -n "$LAST_EVENTS" ]; then
350363
fi
351364
fi
352365

353-
if [ -n "$NO_MOVE_IDS_CSV" ]; then
354-
IFS=',' read -r -a NO_MOVE_IDS <<< "$NO_MOVE_IDS_CSV"
355-
fi
356-
357366
# Function to restructure flat event list into Year -> Month -> List structure
358367
restructure_events_json() {
359368
echo "Restructuring data..."
@@ -401,6 +410,30 @@ normalize_event_base_id() {
401410
printf '%s' "$event_id"
402411
}
403412

413+
# Function to load protected event IDs from -n/--no-move file.
414+
# Empty lines and lines starting with "#" are ignored.
415+
load_no_move_ids() {
416+
local line
417+
418+
NO_MOVE_IDS=()
419+
420+
if [ -z "$NO_MOVE_IDS_FILE" ]; then
421+
return 0
422+
fi
423+
424+
while IFS= read -r line || [ -n "$line" ]; do
425+
line=$(trim_spaces "$line")
426+
427+
if [ -z "$line" ] || [[ "$line" == \#* ]]; then
428+
continue
429+
fi
430+
431+
NO_MOVE_IDS+=("$line")
432+
done < "$NO_MOVE_IDS_FILE"
433+
434+
echo_date "Loaded ${#NO_MOVE_IDS[@]} protected event ID(s) from $NO_MOVE_IDS_FILE"
435+
}
436+
404437
# Function to check if an event is protected by -n/--no-move
405438
# Parameters:
406439
# $1 - event_id: directory name to check
@@ -583,6 +616,7 @@ move_old_events_to_storage() {
583616
cutoff_epoch=$((now_epoch - (MOVE_DAYS * 86400)))
584617

585618
echo_date "Moving events older than ${MOVE_DAYS} day(s) from $DATA_DIR to $DATA_STORAGE_DIR"
619+
load_no_move_ids
586620

587621
while IFS= read -r event_xml; do
588622
found_events=1

publiccode.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name: "INGV - ShakeMap4 Web Page"
77
releaseDate: 2026-05-14
88
url: "https://github.com/INGV/shakemap4-web"
99
landingURL: "https://github.com/INGV/shakemap4-web"
10-
softwareVersion: v2.10.0
10+
softwareVersion: v2.11.0
1111
developmentStatus: stable
1212
softwareType: standalone/other
1313
platforms:

0 commit comments

Comments
 (0)