From bd1ad2f9489e1b4bf5e3e2a18ddd9f1f698e3e6f Mon Sep 17 00:00:00 2001 From: cruizba Date: Wed, 8 Sep 2021 14:30:04 +0200 Subject: [PATCH] deployment: Add timeout to testRecording.sh to always remove the container in case of error. Add testRecording to CE --- .../ce/aws/cfn-mkt-ov-ce-ami.yaml.template | 26 +++++++++++++++++++ .../pro/aws/cfn-mkt-kms-ami.yaml.template | 7 ++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/openvidu-server/deployments/ce/aws/cfn-mkt-ov-ce-ami.yaml.template b/openvidu-server/deployments/ce/aws/cfn-mkt-ov-ce-ami.yaml.template index 28c7ada4..ff872167 100644 --- a/openvidu-server/deployments/ce/aws/cfn-mkt-ov-ce-ami.yaml.template +++ b/openvidu-server/deployments/ce/aws/cfn-mkt-ov-ce-ami.yaml.template @@ -100,6 +100,30 @@ Resources: mode: "000755" owner: "root" group: "root" + "/usr/local/bin/testRecording.sh": + content: | + #!/bin/bash -x + TEST_RECORDING_DIR="/opt/openvidu/test-recording" + + docker run -d --rm --name=test-recording -e URL=https://openvidu.io/ -v "${TEST_RECORDING_DIR}":/recordings openvidu/openvidu-recording:2.19.0 + + # Wait to file to be created + TIMEOUT_WAIT_FILE=30 + ELAPSED=0 + while [[ ! -f "${TEST_RECORDING_DIR}/video/video.mp4" ]] && [[ "${ELAPSED}" -lt "${TIMEOUT_WAIT_FILE}" ]]; do + sleep 1; + ELAPSED=$((ELAPSED+1)) + done + + # Sleep 30 seconds + sleep 30 + + # Clean test recording + docker rm -f test-recording + rm -rf "${TEST_RECORDING_DIR}" + mode: "000755" + owner: "root" + group: "root" Properties: ImageId: !FindInMap [AMIMAP, !Ref 'AWS::Region', AMI] InstanceType: "t2.2xlarge" @@ -125,6 +149,8 @@ Resources: /usr/local/bin/getDockerImages.sh || { echo "[OpenVidu] error getting docker images"; exit 1; } + echo "@reboot /usr/local/bin/testRecording.sh >> /var/log/testRecording.log 2>&1" | crontab + # sending the finish call /usr/local/bin/cfn-signal -e $? --stack ${AWS::StackId} --resource WaitCondition --region ${AWS::Region} diff --git a/openvidu-server/deployments/pro/aws/cfn-mkt-kms-ami.yaml.template b/openvidu-server/deployments/pro/aws/cfn-mkt-kms-ami.yaml.template index 59430bc8..51a4abb9 100644 --- a/openvidu-server/deployments/pro/aws/cfn-mkt-kms-ami.yaml.template +++ b/openvidu-server/deployments/pro/aws/cfn-mkt-kms-ami.yaml.template @@ -98,7 +98,12 @@ Resources: docker run -d --rm --name=test-recording -e URL=https://openvidu.io/ -v "${TEST_RECORDING_DIR}":/recordings openvidu/openvidu-recording:2.19.0 # Wait to file to be created - while [ ! -f "${TEST_RECORDING_DIR}/video/video.mp4" ]; do sleep 1; done + TIMEOUT_WAIT_FILE=30 + ELAPSED=0 + while [[ ! -f "${TEST_RECORDING_DIR}/video/video.mp4" ]] && [[ "${ELAPSED}" -lt "${TIMEOUT_WAIT_FILE}" ]]; do + sleep 1; + ELAPSED=$((ELAPSED+1)) + done # Sleep 30 seconds sleep 30