Skip to content

Commit 15bb35e

Browse files
Feat/cronjob readonly container (#27)
* Allow running jobs with tracking * Fix testsuite for new entrypoints * chore(dockerfile): use syntax 1.15 to enable advanced BuildKit features * FromAsCasing: 'as' and 'FROM' keywords' casing do not match * Fix: UndefinedVar: Usage of undefined variable '$PHP_EXT_SQLSRV_VERSION' * Allow running in readonly container * Fix: missing folders * chore: refactor scripts sequence * Fix: Healthcheck log * chore: logging --------- Co-authored-by: [email protected] <[email protected]>
1 parent 119d150 commit 15bb35e

File tree

7 files changed

+22
-19
lines changed

7 files changed

+22
-19
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
log "INFO" "| Create required folders"
4+
5+
OUTDIR="${APP_CONFIG_DIR} ${APP_LOG_DIR} ${APP_CACHE_DIR}"
6+
7+
mkdir -p $OUTDIR

bin/container-entrypoint.d/elasticms.d/10-supervisor.sh renamed to bin/container-entrypoint.d/elasticms.d/20-supervisor.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#!/usr/bin/env bash
22

3-
echo " - Configure Supervisord ..."
3+
log "INFO" "| Configure Supervisor"
44

5-
OUTDIR="/app/etc"
5+
OUTDIR="/app/etc /app/var/run /app/var/log"
66
mkdir -p $OUTDIR
77

88
apply-template /app/config/supervisord.conf.tmpl /app/etc/supervisord.conf

bin/container-entrypoint.d/elasticms.d/20-supercronic.sh renamed to bin/container-entrypoint.d/elasticms.d/21-supercronic.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,36 @@
33
OUTDIR="/app/etc/crontabs /app/etc/supervisor.d"
44
mkdir -p $OUTDIR
55

6-
echo " - Writing Supercronic crontab file..."
6+
log "INFO" "| Configure Supercronic"
77

88
if [[ -f /app/etc/crontabs/elasticms ]]
99
then
1010

1111
if rm /app/etc/crontabs/elasticms; then
1212
apply-template /app/config/elasticms.crontab.tmpl /app/etc/crontabs/elasticms
1313
else
14-
echo " - Supercronic crontab file exists and will be used ..."
14+
log "WARN" "| Supercronic crontab file exists and will be used"
1515
fi
1616

1717
else
1818

19+
log "INFO" "| Writing Supercronic crontab file"
1920
apply-template /app/config/elasticms.crontab.tmpl /app/etc/crontabs/elasticms
2021

2122
fi
2223

23-
echo " - Configure Supervisord for Supercronic usage..."
24-
2524
if [[ -f /app/etc/supervisor.d/supercronic.ini ]]
2625
then
2726

2827
if rm /app/etc/supervisor.d/supercronic.ini; then
2928
apply-template /app/config/supercronic.ini.tmpl /app/etc/supervisor.d/supercronic.ini
3029
else
31-
echo " - Supervisord config file exists and will be used ..."
30+
log "WARN" "| Supervisor config file exists and will be used"
3231
fi
3332

3433
else
3534

35+
log "INFO" "| Writing Supervisor config file for Supercronic usage"
3636
apply-template /app/config/supercronic.ini.tmpl /app/etc/supervisor.d/supercronic.ini
3737

3838
fi

bin/container-entrypoint.d/post_cronjob.d/post.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ export ELASTICMS_CLI_JOB_ENDTIME=`date +%s`
55

66
rm -f ${ELASTICMS_CLI_LOG_TMP_FILE}
77

8-
echo "--------------------------------------"
9-
echo "Finished Job at $(date +"%Y-%m-%d %H:%M:%S") after $((ELASTICMS_CLI_JOB_ENDTIME-ELASTICMS_CLI_JOB_STARTTIME)) seconds"
10-
echo "======================================"
8+
logLast "───────────────────────────────────────"
9+
logLast "Finished at $(date +"%Y-%m-%d %H:%M:%S") after $((ELASTICMS_CLI_JOB_ENDTIME-ELASTICMS_CLI_JOB_STARTTIME)) seconds"
10+
logLast "───────────────────────────────────────"

bin/container-entrypoint.d/pre_cronjob.d/pre.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ source "${ELASTICMS_CLI_PRE_CRONJOB_PATH}/lib/helper.bash"
55

66
export ELASTICMS_CLI_JOB_STARTTIME=`date +%s`
77

8-
echo "======================================"
9-
echo "Starting Job at $(date +"%Y-%m-%d %H:%M:%S")"
10-
echo "--------------------------------------"
8+
logLast "───────────────────────────────────────"
9+
logLast "Starting at $(date +"%Y-%m-%d %H:%M:%S")"
10+
logLast "───────────────────────────────────────"

bin/elasticms-cronjob

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@ set -eo pipefail
44
export DEBUG=${DEBUG:-false}
55
[[ "${DEBUG}" == "true" ]] && set -x
66

7-
echo -e "\n Configure ElasticMS CLI Container ( Cronjob ) ...\n"
8-
97
export ELASTICMS_CLI_JOB_COMMAND="$@"
108

119
for FILE in $(find /app/bin/container-entrypoint.d/entrypoint.d -iname \*.sh | sort)
1210
do
1311
source ${FILE}
1412
done
1513

16-
echo -e "\n ElasticMS CLI Container configured succesfully ...\n"
14+
log "INFO" "| ElasticMS CLI Container ( Cronjob ) configured succesfully"
1715

1816
exec elasticms-job "${ELASTICMS_CLI_JOB_COMMAND}"

bin/elasticms-crontab

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ set -eo pipefail
44
export DEBUG=${DEBUG:-false}
55
[[ "${DEBUG}" == "true" ]] && set -x
66

7-
echo -e "\n Configure ElasticMS CLI Container ( Crontab )...\n"
8-
97
export ELASTICMS_CLI_CROND_COMMAND="$@"
108

119
for FILE in $(find /app/bin/container-entrypoint.d/entrypoint.d -iname \*.sh | sort)
@@ -18,6 +16,6 @@ do
1816
source ${FILE}
1917
done
2018

21-
echo -e "\n ElasticMS CLI Container configured succesfully ...\n"
19+
log "INFO" "| ElasticMS CLI Container ( Crontab ) configured succesfully"
2220

2321
exec /usr/bin/supervisord -c /app/etc/supervisord.conf

0 commit comments

Comments
 (0)