Skip to content

Commit

Permalink
add support for cronjobs
Browse files Browse the repository at this point in the history
  • Loading branch information
jimdaga committed Oct 25, 2023
1 parent 378773a commit f9250db
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
41 changes: 41 additions & 0 deletions charts/family-pickem/templates/cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
apiVersion: batch/v1
kind: CronJob
metadata:
name: {{ include "family-pickem.fullname" . }}-update-data
labels:
{{- include "family-pickem.labels" . | nindent 4 }}
spec:
schedule: "{{ .Values.cron.schedule }}"
suspend: {{ .Values.cron.suspend }}
successfulJobsHistoryLimit: {{ .Values.cron.successfulJobsHistoryLimit }}
failedJobsHistoryLimit: {{ .Values.cron.failedJobsHistoryLimit }}
concurrencyPolicy: {{ .Values.cron.concurrencyPolicy }}
startingDeadlineSeconds: 86400 # Allow for 1 day of missed starts, before being counted as a single miss (max 100 misses)
jobTemplate:
spec:
template:
spec:
serviceAccountName: {{ include "family-pickem.serviceAccountName" . }}
containers:
- name: {{ .Values.fullnameOverride }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: IfNotPresent
command: [ "/bin/bash", "-c" ]
args:
- |
{{ .Values.cron.command }}
resources:
{{- toYaml .Values.resources | nindent 16 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 12 }}
{{- end }}
restartPolicy: OnFailure
44 changes: 44 additions & 0 deletions pickem/pickem_api/cron.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

# update games
echo "################################################################"
echo "#"
echo "# Running: /code/pickem_api/cron_update_games_v2.py"
echo "#"
echo "################################################################"
echo
python /code/pickem_api/cron_update_games_v2.py

# update picks
echo
echo "################################################################"
echo "#"
echo "# Running: /code/pickem_api/cron_update_picks.py"
echo "#"
echo "################################################################"
echo
python /code/pickem_api/cron_update_picks.py

# update team standings
echo
echo
echo "################################################################"
echo "#"
echo "# Running: /code/pickem_api/cron_update_records.py"
echo "#"
echo "################################################################"
echo
python /code/pickem_api/cron_update_records.py

# Update overall standings
echo
echo
echo "################################################################"
echo "#"
echo "# Running: /code/pickem_api/cron_update_standings.py"
echo "#"
echo "################################################################"
echo
python /code/pickem_api/cron_update_standings.py
echo
exit 0

0 comments on commit f9250db

Please sign in to comment.