Skip to content

Commit e352371

Browse files
committed
Add retry to start runtime
1 parent 1424fe9 commit e352371

2 files changed

Lines changed: 51 additions & 24 deletions

File tree

.github/actions/start-runtime/action.yml

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,40 +14,39 @@ runs:
1414
uses: actions/setup-python@v4.5.0
1515
with:
1616
python-version: "3.x"
17+
1718
- name: "Install Python dependencies"
1819
run: pip install pyaml httplib2
1920
shell: bash
21+
2022
- name: "Setup Java 21"
2123
id: setup-java
2224
uses: actions/setup-java@3a4f6e1af504cf6a31855fa899c6aa5355ba6c12 #v4
2325
with:
2426
distribution: "temurin"
2527
java-version: "21"
26-
- name: "Extract deployment package"
27-
run: |
28-
mkdir project
29-
unzip -qq ${{ inputs.mda-file }} -d project
30-
cp configs/e2e/m2ee-native.yml project/m2ee-native.yml
31-
sed -i -- 's=$ROOT_PATH=${{ github.workspace }}=g' project/m2ee-native.yml
32-
sed -i -- 's=$JAVA_HOME=${{ steps.setup-java.outputs.path }}=g' project/m2ee-native.yml
28+
29+
- name: "Make setup-runtime.sh executable"
30+
run: chmod +x .github/scripts/setup-runtime.sh
3331
shell: bash
34-
- name: "Setup m2ee"
32+
33+
- name: "Initial setup"
3534
run: |
36-
mkdir -p var/log var/opt/m2ee var/run bin tmp
37-
git clone https://github.com/KevinVlaanderen/m2ee-tools.git tmp/m2ee
38-
mv tmp/m2ee/src/* var/opt/m2ee
39-
chmod a=rwx var/log/ var/run/
40-
echo "#!/bin/bash -x" > bin/m2ee
41-
echo "python3 var/opt/m2ee/m2ee.py \$@" >>bin/m2ee
42-
chmod +x bin/m2ee
35+
.github/scripts/setup-runtime.sh "${{ inputs.mda-file }}" "${{ inputs.mendix-version }}" "${{ steps.setup-java.outputs.path }}" "${{ github.workspace }}"
4336
shell: bash
44-
- name: "Setup mxruntime"
37+
38+
- name: "Start mxruntime with retries"
4539
run: |
46-
mkdir -p ${{ github.workspace }}/project/runtimes ${{ github.workspace }}/project/data/model-upload ${{ github.workspace }}/project/data/database ${{ github.workspace }}/project/data/files ${{ github.workspace }}/project/data/tmp
47-
wget -q https://cdn.mendix.com/runtime/mendix-${{ inputs.mendix-version }}.tar.gz -O tmp/runtime.tar.gz
48-
tar xfz tmp/runtime.tar.gz --directory ${{ github.workspace }}/project/runtimes
49-
rm tmp/runtime.tar.gz
50-
shell: bash
51-
- name: "Start mxruntime"
52-
run: bin/m2ee -c ${{ github.workspace }}/project/m2ee-native.yml --verbose --yolo start
53-
shell: bash
40+
set -e
41+
MAX_RETRIES=3
42+
RETRY=0
43+
until bin/m2ee -c ${{ github.workspace }}/project/m2ee-native.yml --verbose --yolo start; do
44+
RETRY=$((RETRY+1))
45+
if [ $RETRY -ge $MAX_RETRIES ]; then
46+
echo "mxruntime failed after $MAX_RETRIES attempts."
47+
exit 1
48+
fi
49+
echo "mxruntime failed, retrying ($RETRY/$MAX_RETRIES)..."
50+
.github/scripts/setup-runtime.sh "${{ inputs.mda-file }}" "${{ inputs.mendix-version }}" "${{ steps.setup-java.outputs.path }}" "${{ github.workspace }}"
51+
done
52+
shell: bash

.github/scripts/setup-runtime.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
set -e
3+
4+
MDA_FILE="$1"
5+
MENDIX_VERSION="$2"
6+
JAVA_PATH="$3"
7+
WORKSPACE="$4"
8+
9+
rm -rf project var tmp bin
10+
11+
mkdir project
12+
unzip -qq "$MDA_FILE" -d project
13+
cp configs/e2e/m2ee-native.yml project/m2ee-native.yml
14+
sed -i -- "s=\$ROOT_PATH=$WORKSPACE=g" project/m2ee-native.yml
15+
sed -i -- "s=\$JAVA_HOME=$JAVA_PATH=g" project/m2ee-native.yml
16+
17+
mkdir -p var/log var/opt/m2ee var/run bin tmp
18+
git clone https://github.com/KevinVlaanderen/m2ee-tools.git tmp/m2ee
19+
mv tmp/m2ee/src/* var/opt/m2ee
20+
chmod a=rwx var/log/ var/run/
21+
echo "#!/bin/bash -x" > bin/m2ee
22+
echo "python3 var/opt/m2ee/m2ee.py \$@" >>bin/m2ee
23+
chmod +x bin/m2ee
24+
25+
mkdir -p "$WORKSPACE/project/runtimes" "$WORKSPACE/project/data/model-upload" "$WORKSPACE/project/data/database" "$WORKSPACE/project/data/files" "$WORKSPACE/project/data/tmp"
26+
wget -q "https://cdn.mendix.com/runtime/mendix-$MENDIX_VERSION.tar.gz" -O tmp/runtime.tar.gz
27+
tar xfz tmp/runtime.tar.gz --directory "$WORKSPACE/project/runtimes"
28+
rm tmp/runtime.tar.gz

0 commit comments

Comments
 (0)