Skip to content

Commit c8436bd

Browse files
authored
Merge pull request #33 from flownative/feature/multiple-custom-hooks
FEATURE: Adds multiple hooks on startup
2 parents 5842ac3 + b1fc687 commit c8436bd

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

root-files/entrypoint.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ if [[ "$*" = *"run"* ]]; then
6262
set +o errexit
6363
supervisorctl status 2>&1 | (sed 's/^/Supervisor: /' | output)
6464
set -o errexit
65+
66+
beach_startup_complete
67+
6568
info "Entrypoint: Start up complete"
6669
# We can't use "wait" because supervisord is not a direct child of this shell:
6770
while [ -e "/proc/${supervisor_pid}" ]; do sleep 1.1; done

root-files/opt/flownative/lib/beach.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,24 @@ beach_run_custom_startup() {
206206
"${BEACH_APPLICATION_PATH}/beach-startup.sh" 2>&1 | (sed 's/^/Beach: (flow) /' | output)
207207
}
208208

209+
beach_run_specified_hook() {
210+
if [ -n "$1" ]; then
211+
if is_boolean_yes "$BEACH_APPLICATION_CUSTOM_STARTUP_SCRIPTS_ENABLE"; then
212+
if [ ! -f "${BEACH_APPLICATION_PATH}/$1.sh" ]; then
213+
info "Beach: No $1.sh found, skipping hook"
214+
return
215+
fi
216+
info "Beach: Running '$1' hook ($1.sh) ..."
217+
chmod +x "${BEACH_APPLICATION_PATH}/$1.sh"
218+
"${BEACH_APPLICATION_PATH}/$1.sh" 2>&1 | (sed 's/^/Beach: (flow) /' | output)
219+
else
220+
info "Beach: Skipping '$1' hook because custom startup scripts are disabled"
221+
fi
222+
else
223+
warn "No hook name given to run hook function, this should not happen"
224+
fi
225+
}
226+
209227
# ---------------------------------------------------------------------------------------
210228
# beach_run_sitemap_crawler() - Invoke a crawler which warms up caches for all urls of a sitemap
211229
#
@@ -315,6 +333,8 @@ beach_initialize() {
315333
beach_setup_user_profile
316334
beach_setup_igbinary
317335
beach_setup_addon_blackfire
336+
337+
beach_run_specified_hook "beach-hook-initialize"
318338
}
319339

320340
# ---------------------------------------------------------------------------------------
@@ -344,6 +364,7 @@ beach_prepare_flow() {
344364
else
345365
info "Beach: Skipping custom startup scripts"
346366
fi
367+
beach_run_specified_hook "beach-hook-warmup"
347368

348369
beach_enable_user_services
349370
}
@@ -364,7 +385,12 @@ beach_finalize_flow() {
364385
info "Beach: Running sitemap crawler ..."
365386
beach_run_sitemap_crawler
366387
fi
388+
}
367389

390+
beach_startup_complete() {
391+
beach_run_specified_hook "beach-hook-ready"
368392
debug "Beach: Writing .warmupdone flag"
369393
touch /application/.warmupdone
394+
info ".warmupdone written, this pod will now become ready"
395+
beach_run_specified_hook "beach-hook-live"
370396
}

0 commit comments

Comments
 (0)