Skip to content

Commit

Permalink
Change how right start command is chosen to improve reliability
Browse files Browse the repository at this point in the history
  • Loading branch information
nygrenh committed May 24, 2024
1 parent a92cc04 commit 218bdf0
Show file tree
Hide file tree
Showing 16 changed files with 35 additions and 75 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ spec:
containers:
- name: calculate-page-visit-stats
image: headless-lms
command: ["cargo", "run", "--", "calculate-page-visit-stats"]
command: ["bin/run", "calculate-page-visit-stats"]
resources:
requests:
memory: 100Mi
Expand Down
2 changes: 1 addition & 1 deletion kubernetes/base/headless-lms/ended-exams-processor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ spec:
containers:
- name: ended-exams-processor
image: headless-lms
command: ["cargo", "run", "--", "ended-exams-processor"]
command: ["bin/run", "ended-exams-processor"]
resources:
requests:
memory: 100Mi
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,7 @@ spec:
containers:
- name: open-university-registration-link-fetcher
image: headless-lms
command:
[
"cargo",
"run",
"--",
"open-university-registration-link-fetcher",
]
command: ["bin/run", "open-university-registration-link-fetcher"]
resources:
requests:
memory: 100Mi
Expand Down
8 changes: 1 addition & 7 deletions kubernetes/base/headless-lms/peer-review-updater.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,7 @@ spec:
containers:
- name: peer-review-updater
image: headless-lms
command:
[
"cargo",
"run",
"--",
"peer-review-updater",
]
command: ["bin/run", "peer-review-updater"]
resources:
requests:
memory: 100Mi
Expand Down
2 changes: 1 addition & 1 deletion kubernetes/base/headless-lms/regrader.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ spec:
containers:
- name: regrader
image: headless-lms
command: ["cargo", "run", "--", "regrader"]
command: ["bin/run", "regrader"]
resources:
requests:
memory: 100Mi
Expand Down
2 changes: 1 addition & 1 deletion kubernetes/base/headless-lms/service-info-fetcher.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ spec:
containers:
- name: service-info-fetcher
image: headless-lms
command: ["cargo", "run", "--", "service-info-fetcher"]
command: ["bin/run", "service-info-fetcher"]
resources:
requests:
memory: 100Mi
Expand Down
8 changes: 1 addition & 7 deletions kubernetes/base/headless-lms/sync-tmc-users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,7 @@ spec:
containers:
- name: sync-tmc-users
image: headless-lms
command:
[
"cargo",
"run",
"--",
"sync-tmc-users",
]
command: ["bin/run", "sync-tmc-users"]
resources:
requests:
memory: 100Mi
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions kubernetes/production/headless-lms/patch-regrader.yml

This file was deleted.

This file was deleted.

31 changes: 0 additions & 31 deletions kubernetes/production/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,6 @@ patches:
version: v1
kind: Ingress
name: project-331-other-domains
# Patch to use --release param in cargo command
- path: headless-lms/patch-service-info-fetcher.yml
target:
version: v1
kind: Deployment
name: service-info-fetcher
- path: headless-lms/patch-ended-exams-processor.yml
target:
version: v1
kind: CronJob
name: ended-exams-processor
- path: headless-lms/patch-calculate-page-visit-stats.yml
target:
version: v1
kind: CronJob
name: calculate-page-visit-stats
- path: headless-lms/patch-open-university-registration-link-fetcher.yml
target:
version: v1
kind: CronJob
name: open-university-registration-link-fetcher
- path: headless-lms/patch-peer-review-updater.yml
target:
version: v1
kind: CronJob
name: peer-review-updater
- path: headless-lms/patch-regrader.yml
target:
version: v1
kind: Deployment
name: regrader
- path: ./headless-lms/patch-add-db-host-aliases.yml
target:
version: v1
Expand Down
3 changes: 2 additions & 1 deletion services/headless-lms/Dockerfile.production.slim.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ COPY --from=builder /bins /app
COPY --from=builder /app/migrations /app/migrations
COPY --from=builder /app/wait-for-db.sh /app/
COPY --from=builder /app/wait-for-db-migrations.sh /app/
COPY --from=builder /app/bin/run /app/bin/run

# Used in the test mode
RUN mkdir uploads && chown -R user uploads
Expand All @@ -28,4 +29,4 @@ COPY --from=builder /icu4x.postcard /icu4x.postcard

USER user

CMD [ "./headless-lms-entrypoint", "start-server" ]
CMD [ "bin/run", "start-server" ]
26 changes: 26 additions & 0 deletions services/headless-lms/bin/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash
set -euo pipefail

BASEDIR="$(dirname "${BASH_SOURCE[0]}")"
FOLDER_PATH="$BASEDIR/.."
ABSOLUTE_PATH=$(realpath "$FOLDER_PATH")

# Cd to the root of the headless-lms folder
echo "\$ cd $ABSOLUTE_PATH"
cd "$ABSOLUTE_PATH" || exit


if [ "$#" -eq 0 ]; then
echo "Error: Please give the program name as an argument e.g. \"./run.sh start-server\""
exit 1
fi

if [ -f "headless-lms-entrypoint" ]; then
# This happens in production and in bin/test
echo "\$ ./headless-lms-entrypoint $*"
exec ./headless-lms-entrypoint "$*"
else
# This happens in bin/dev
echo "\$ cargo run -- $*"
exec cargo run -- "$*"
fi

0 comments on commit 218bdf0

Please sign in to comment.