generated from bisco/codex-bootstrap
feat: add internal WordPress cron runner
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
|
||||
cd /var/www/html
|
||||
|
||||
trap 'exit 0' INT TERM
|
||||
|
||||
interval="${WP_CRON_INTERVAL_SECONDS:-300}"
|
||||
case "$interval" in
|
||||
"" | *[!0-9]*)
|
||||
echo "WP_CRON_INTERVAL_SECONDS must be a positive integer." >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "$interval" -lt 60 ]; then
|
||||
echo "WP_CRON_INTERVAL_SECONDS must be at least 60 seconds." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
while [ ! -f /var/www/html/wp-load.php ]; do
|
||||
sleep 10
|
||||
done
|
||||
|
||||
until wp core is-installed >/dev/null 2>&1; do
|
||||
sleep 10
|
||||
done
|
||||
|
||||
while :; do
|
||||
if ! wp cron event run --due-now >/dev/null 2>&1; then
|
||||
echo "Warning: failed to run due WordPress cron events." >&2
|
||||
fi
|
||||
|
||||
sleep "$interval" &
|
||||
wait "$!"
|
||||
done
|
||||
Reference in New Issue
Block a user