Skip to content

KickOffService

KickOffService #17789

# I'm using heroku for serving the live audience (app in playstore, see readme for link)
# Since I'm running on a free-tire mode heroku will shutdown the app after some amount of inactivity.
# so user logging in during that time have to face atleaset one api call failure before proceeding, which is causing bad experience.
# hence created this action to invoke my backend every 5 minute to keep the service alive.
name: KickOffService
# Controls when the workflow will run
on:
# Triggers the workflow every 30 minute
schedule:
- cron: "*/45 * * * *"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
invoke_backend_server:
# The type of runner that the job will run on
runs-on: ubuntu-latest
env:
PROD_URL: ${{ secrets.PROD_URL }}
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Invoke backend
run: |
echo "Begin launch service"
num_of_hit=1;
while [ $num_of_hit -le 5 ]; do
http_status=$(curl -o /dev/null -s -w "%{http_code}" ${{env.PROD_URL}})
if [ "$http_status" = 200 ]; then
echo "Success hit_index = $num_of_hit"
break;
else
echo "Failure hit_count = $num_of_hit"
fi
((num_of_hit++));
echo "wait for 5 seconds before invoking the server again."
sleep 5
done
echo "End launch service."