Skip to content

Commit

Permalink
Cron now also runs under alpine Linux (#31)
Browse files Browse the repository at this point in the history
* fix deploy when cron is failing

* Cron now also runs under alpine Linux
  • Loading branch information
henzigo authored Nov 26, 2024
1 parent 979d5ca commit dd63466
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
2. Run `composer update shopsys/deployment`
3. Check files in mentioned pull requests and if you have any of them extended in your project, apply changes manually

## Upgrade from v3.2.9 to v3.3.0

- Cron can run under Alpine Linux ([#31](https://github.com/shopsys/deployment/pull/31))

## Upgrade from v3.2.7 to v3.2.9

- Added routes to Nginx ([Commit](https://github.com/shopsys/deployment/commit/5b378a3ee1131fed8ac2821158f03f667db19dcb))
Expand Down
2 changes: 1 addition & 1 deletion deploy/parts/cron.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ assertVariable "CONFIGURATION_TARGET_PATH"
ITERATOR=0
for key in ${!CRON_INSTANCES[@]}; do

CRONTAB_LINE=" ${CRON_INSTANCES[${key}]} root . /root/.project_env.sh && cd /var/www/html && ./phing ${key} > /dev/null 2>&1"
CRONTAB_LINE=" ${CRON_INSTANCES[${key}]} . /root/.project_env.sh && cd /var/www/html/ && ./phing ${key} > /dev/null 2>&1"
echo "${CRONTAB_LINE}" >> "${CONFIGURATION_TARGET_PATH}/configmap/cron-list.yaml"

ITERATOR=$(expr $ITERATOR + 1)
Expand Down
2 changes: 1 addition & 1 deletion deploy/parts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ if [ ${RUNNING_PRODUCTION} -eq "0" ]; then
echo -e "[${GREEN}OK${NO_COLOR}]"
fi

DEPLOYED_CRON_POD=$(kubectl get pods --namespace=${PROJECT_NAME} --field-selector=status.phase=Running -l app=cron -o=jsonpath='{.items[0].metadata.name}') || true
DEPLOYED_CRON_POD=$(kubectl get pods --namespace=${PROJECT_NAME} --field-selector=status.phase=Running -l app=cron -o=jsonpath='{.items[?(@.status.containerStatuses[0].state.running)].metadata.name}') || true

if [[ -n ${DEPLOYED_CRON_POD} ]]; then
echo -n "Lock crons to prevent run next iteration "
Expand Down
4 changes: 2 additions & 2 deletions kubernetes/deployments/cron.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ spec:
imagePullPolicy: Always
workingDir: /var/www/html
command: ["/bin/sh","-c"]
args: ["cd /var/www/html && ./phing warmup > /dev/null && rm -rf /tmp/log-pipe && mkfifo /tmp/log-pipe && chmod 666 /tmp/log-pipe && cron && stdbuf -o0 tail -n +1 -f /tmp/log-pipe"]
args: ["cd /var/www/html && ./phing warmup > /dev/null && rm -rf /tmp/log-pipe && mkfifo /tmp/log-pipe && chmod 666 /tmp/log-pipe && crontab -u root /var/spool/cron/template && { crond || cron; } && stdbuf -o0 tail -n +1 -f /tmp/log-pipe"]
lifecycle:
preStop:
exec:
Expand All @@ -54,7 +54,7 @@ spec:
mountPath: /var/www/html/{{DOMAINS_URLS_FILEPATH}}
subPath: "{{DOMAINS_URLS_FILENAME}}"
- name: cron-list
mountPath: /etc/cron.d/cron
mountPath: /var/spool/cron/template
subPath: cron
- name: cron-env
mountPath: /root/.project_env.sh
Expand Down

0 comments on commit dd63466

Please sign in to comment.