-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
ansible/roles/library-cron-job/api-library-management-cronjob.yml.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
apiVersion: batch/v1 | ||
kind: CronJob | ||
metadata: | ||
namespace: {{ NAMESPACE }} | ||
labels: | ||
app: api-library-management-cronjob | ||
name: api-library-management-cronjob | ||
spec: | ||
schedule: "{{ SERVER_LIBRARY_MANAGEMENT_CRONJOB|default("0 3 * * 3,6", true) }}" | ||
concurrencyPolicy: Forbid | ||
jobTemplate: | ||
spec: | ||
activeDeadlineSeconds: {{ SERVER_LIBRARY_MANAGEMENT_CRONJOB_TIMEOUT|default("39600", true) }} | ||
template: | ||
spec: | ||
containers: | ||
- name: api-library-management-cronjob | ||
image: {{ SCHULCLOUD_SERVER_IMAGE }}:{{ SCHULCLOUD_SERVER_IMAGE_TAG }} | ||
envFrom: | ||
- configMapRef: | ||
name: api-configmap | ||
- secretRef: | ||
name: api-secret | ||
command: ['/schulcloud-server/scripts/ldapSync.sh'] | ||
resources: | ||
limits: | ||
cpu: {{ API_CPU_LIMITS|default("2000m", true) }} | ||
memory: {{ API_MEMORY_LIMITS|default("2Gi", true) }} | ||
requests: | ||
cpu: {{ API_CPU_REQUESTS|default("100m", true) }} | ||
memory: {{ API_MEMORY_REQUESTS|default("150Mi", true) }} | ||
restartPolicy: OnFailure |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/bin/sh | ||
set -eu | ||
|
||
default_time_out=39600 | ||
value_time_out=${SERVER_LIBRARY_MANAGEMENT_CRONJOB_TIMEOUT:-$default_time_out} | ||
|
||
default_api_key="example" | ||
value_api_key="${SYNC_API_KEY:-$default_api_key}" | ||
|
||
# Start server in the background and redirect logs to file | ||
nohup npm run nest:start > server.log 2>&1 & | ||
|
||
# Show logs and wait for server to start up | ||
echo "Server logs:" | ||
tail -f server.log & | ||
|
||
echo "Wait for server to start..." | ||
until curl -s -w --retry 10 --retry-max-time 120 --retry-connrefused --retry-delay 10 http://localhost:3030/serverversion >/dev/null 2>&1; do | ||
sleep 1 | ||
echo "asleep" | ||
done | ||
|
||
# Start sync | ||
echo "Starting" | ||
curl --max-time $value_time_out -H "X-API-Key: $value_api_key" "http://localhost:3030/api/v1/sync?target=ldap&forceFullSync=true" | python3 -m json.tool | ||
|
||
# Process stops automatically and deletes logs with end of job pod |