Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker and Healthcheck adjustments #209

Merged
merged 3 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion saas_app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ RUN apt-get update && apt-get install -y --no-install-recommends \

WORKDIR /saas_app
COPY requirements.txt /saas_app/
RUN pip install -r requirements.txt
RUN pip install --no-cache-dir --upgrade pip \
&& pip install --no-cache-dir -r requirements.txt
COPY . /saas_app/
EXPOSE 8000
ENTRYPOINT ./bin/initialize.sh
28 changes: 7 additions & 21 deletions saas_app/bin/initialize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,6 @@
# Script that validates if the project is properly initilized for development purposes.
# If not, initializes the project.

#Update pip
pip install --upgrade pip

# Check if django is installed, if not, install requirements_dev.txt
django_installed=$(pip3 list | grep -c django)
if [ "${django_installed}" -eq 0 ]; then
echo "Django is not installed"
echo "Installing requirements_dev.txt"
python -m pip install -r requirements.txt
python -m pip install -r requirements_dev.txt
else
echo "Django is installed, skipping requirements_dev.txt"
echo "If you want to manually update the project packages, run: pip install -r requirements_dev.txt"
fi

echo "Retrieving environment parameters and put them in an .env file"
python bin/get_parameters.py

Expand Down Expand Up @@ -85,22 +70,23 @@ touch logs/cronjob.log
# Add the crontab entry so that we can run it every day
echo "Starting cron service"
# Start the cron service
/etc/init.d/cron start
service cron start
# Get the status of the cron service
service cron status

# Add the crontab entry
echo "Setting up crontab"
python manage.py crontab remove
python manage.py crontab add
# print out the value to make sure that we are doing it properly
python manage.py crontab show
cronjob_id=$(python manage.py crontab add | grep -o '\([a-f0-9]\{32\}\)')
# Now if we are testing and the database is empty, make sure that we run the cronjob once to populate the database with data
logs=$(python manage.py shell -c "from manage_saas.models import GoogleWorkspaceAppsLogin; print(len(GoogleWorkspaceAppsLogin.objects.all()))")
if [ "${logs}" -eq 0 ]; then
# Get the cronjob id
cronjob_id=$(python manage.py crontab show | grep -o '^[a-f0-9]\{32\}')
# now run the cronjob to genearte data
python manage.py crontab run ${cronjob_id}
fi

# See if the cron is running
crontab -l

# Start up the application
echo "Starting up the application"
Expand Down
4 changes: 2 additions & 2 deletions terragrunt/aws/load_balancer/load_balancer.tf
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ resource "aws_lb_target_group" "saas_procurement" {

health_check {
enabled = true
interval = 10
interval = 60
path = "/health"
timeout = 5
timeout = 30
healthy_threshold = 2
unhealthy_threshold = 2
}
Expand Down
Loading