Skip to content

Commit

Permalink
Merge branch 'main' into cm-367-ignore-304-and-401
Browse files Browse the repository at this point in the history
  • Loading branch information
dcmcand authored Mar 11, 2021
2 parents fdc34a2 + b9dff4e commit c17ad32
Show file tree
Hide file tree
Showing 6 changed files with 128 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ parameters:
default: "main"
type: string
sandbox_git_branch: # change to feature branch to test deployment
default: "js-152-browser-controls"
default: "cm-363-record-deployments"
type: string
jobs:
build_and_lint:
Expand Down
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,32 @@ You can run psql commands directly against a deployed database by following thes
On success, your terminal prompt will change to match the `db_name` from the database instance credentials.
This indicates you are in an open psql session, the command-line interface to PostgreSQL.

**Using Maintenance Mode**

if you need to put the application into maintenance mode, you can run the maintenance script located at `bin/maintenance`.

This script require that you have [Cloud Foundry's CLI v7](https://github.com/cloudfoundry/cli/wiki/V7-CLI-Installation-Guide) installed to run.
The script takes two flags
- \-m | \-\-maintenance\-mode controls whether the script takes the app into maintenance mode or out of it.
- Options are "on" or "off
- Default is "off"
- \-e | \-\-environment controls which environment you are targeting.
- Options are "sandbox", "dev", "staging", and "prod"
- Default is "prod"
Ex.
```
# Puts the dev environment into maintenance mode
./bin/maintenance -e dev -m on
# Takes prod out of maintenance mode
./bin/maintenance
```
If you are not logged into the cf cli, it will ask you for an sso temporary password. You can get a temporary password at https://login.fr.cloud.gov/passcode.
<!-- Links -->
[adhoc-main]: https://github.com/adhocteam/Head-Start-TTADP/tree/main
Expand Down
3 changes: 2 additions & 1 deletion Staticfile
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
root: maintenance_page
root: maintenance_page
location_include: includes/*.conf
91 changes: 91 additions & 0 deletions bin/maintenance
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#! /bin/bash

maintenance=
environment=

## On entering maintenance mode, this script will unmap the environments primary route and map it to that environments maintenance page.
## It will then map the maintenance route to the app so we still have access to it.
## On leaving maintenance mode, it will return the primary route to the app and delete the maintenance route


# display usage information
help() {
echo "Usage: maintenance [options...]"
echo " -m, --maintenance-mode boolean value that controls whether maintenance mode is turned on or off. Default is off"
echo " -e, --environment specifies which environment the script is run on. Options are prod, staging, dev, or sandbox. Default is prod"
echo " -h, --help show this help text"
}

if [[ $# < 4 ]]; then
help
exit 1
fi

# Check feature flags and validate input
while [ "$1" != "" ]; do
case $1 in
--maintenance-mode | -m) shift
if [[ "$1" != "on" && "$1" != "off" ]]; then
echo "$1 is not a valid value"
help
exit 1
fi
maintenance=$1
;;
--environment | -e) shift
if [[ "$1" != "prod" && "$1" != "staging" && "$1" != "dev" && "$1" != "sandbox" ]]; then
echo "$1 is not a valid value"
help
exit 1
fi
environment=$1
;;
--help | -h) help
exit 0
;;
*) help
exit 1
;;
esac
shift
done

# Check the cf-cli v7 is available
version=$(cf version | cut -d " " -f 3 | cut -d "." -f 1)
if [[ $version != "7" ]]; then
echo "Cloud Foundry CLI v7 not found. Please install it to continue"
echo "https://github.com/cloudfoundry/cli/wiki/V7-CLI-Installation-Guide"
exit 1
fi

route=tta-smarthub-$environment
domain=app.cloud.gov

if [[ $environment == "prod" ]]; then
route=ttahub
domain=ohs.acf.hhs.gov
fi

# try targeting the correct space and capture the exit status
cf target -o hhs-acf-ohs-tta -s ttahub-$environment > /dev/null

status=$?
# if cf target failed then login

if [[ $status != 0 ]]; then
cf login -a api.fr.cloud.gov -o hhs-acf-ohs-tta -s ttahub-$environment --sso
fi

# Put site into maintenance mode
if [[ $maintenance == "on" ]]; then
cf map-route tta-smarthub-maintenance-page-$environment $domain -n $route
cf unmap-route tta-smarthub-$environment $domain -n $route
echo "The $environment environment is in maintenance mode"
fi

# Bring site out of maintenance mode
if [[ $maintenance == "off" ]]; then
cf map-route tta-smarthub-$environment $domain -n $route
cf unmap-route tta-smarthub-maintenance-page-$environment $domain -n $route
echo "The $environment environment is out of maintenance mode and can be reached at https://$route.$domain"
fi
10 changes: 5 additions & 5 deletions maintenance_page/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TTA Smart Hub</title>
<link rel="stylesheet" href="style.css">
<link rel="shortcut icon" href="logo64.png" type="image/x-icon">
<link rel="stylesheet" href="/style.css">
<link rel="shortcut icon" href="/logo64.png" type="image/x-icon">
</head>
<body>
<header>
<img src="eclkc-blocks-logo.png" alt="TTA Smarthub logo">
<img src="/eclkc-blocks-logo.png" alt="TTA Smarthub logo">
<span>
Office of Head Start TTA Smart Hub
</span>
Expand All @@ -18,9 +18,9 @@
<div class="left-div">
</div>
<main>
<img src="eclkc-blocks-logo.png" alt="TTA Smarthub Logo">
<img src="/eclkc-blocks-logo.png" alt="TTA Smarthub Logo">
<h1>The TTA Smart Hub is temporarily down.</h1>
<p>Due to system maintenance, system services are currently unavilable. Please check back soon.</p>
<p>Due to system maintenance, system services are currently unavailable. Please check back soon.</p>
</main>

</div>
Expand Down
3 changes: 3 additions & 0 deletions nginx/conf/includes/maintenancepage.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
location / {
try_files $uri $uri/ /index.html;
}

0 comments on commit c17ad32

Please sign in to comment.