-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
executable file
·29 lines (24 loc) · 993 Bytes
/
entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/sh
set -e
TEMP_CONFIG="/tmp/config.json"
# Resolve and output the below variables to /tmp/config.json
node /usr/app/dist/src/entrypoint-config.js
export TZ=$(cat $TEMP_CONFIG | jq -r ".timezone")
RUN_ON_STARTUP=$(cat $TEMP_CONFIG | jq -r ".runOnStartup")
RUN_ONCE=$(cat $TEMP_CONFIG | jq -r ".runOnce")
CRON_SCHEDULE=$(cat $TEMP_CONFIG | jq -r ".cronSchedule")
# If runOnStartup is set, run it once before setting up the schedule
echo "Run on startup: ${RUN_ON_STARTUP}"
if [ "$RUN_ON_STARTUP" = "true" ]; then
node /usr/app/dist/src/index.js
fi
# If runOnce is not set, schedule the process
echo "Run once: ${RUN_ONCE}"
if [ "$RUN_ONCE" = "false" ]; then
echo "Setting cron schedule as ${CRON_SCHEDULE}"
# Add the command to the crontab
echo "${CRON_SCHEDULE} node /usr/app/dist/src/index.js" > $HOME/crontab
# Run the cron process. The container should halt here and wait for the schedule.
supercronic -passthrough-logs $HOME/crontab
fi
echo "Exiting..."