cac-tripplanner
cac-tripplanner copied to clipboard
Clean Air Council Circuit Trip Planner and Travelshed
Clean Air Council Circuit Trip Planner and Travelshed
Development Dependencies
Development Installation
- Make sure you have the development dependencies installed
- Place GTFS .zip files, OSM files, and elevation .tif files (optional) in the root of the otp_data folder
- (Optional) Generate a graph file with (takes approx 3 hours)
docker-compose run --rm otp otp --build /var/otpin the deployment/graph directory. - Copy
deployment/ansible/group_vars/development_templatetodeployment/ansible/group_vars/development - Change into the
src/folder and runnpm installto install the node modules on the host machine - Run
vagrant up. You can choose to change the Virtualbox shared folder type for theappVM from its default NFS by:
CAC_APP_SHARED_FOLDER_TYPE=virtualbox vagrant up
- See the app at http://localhost:8024! See OpenTripPlanner at http://localhost:9090.
- Running
./scripts/serve-js-dev.shon the host will rebuild the front-end app on file change (the browser must be reloaded manually to pick up the change). Alternatively,cd /opt/app/src && npm run gulp-developmentcan be run manually in the VM to pick up changes to the static files.
Note that if there is an existing build Graph.obj in otp_data, vagrant provisioning in development mode will not attempt to rebuild the graph, but will use the one already present.
Django migrations are run as part of app provisioning, here, but there may be instances where you need to manually run migrations outside of provisioning, in which case use the command:
vagrant ssh app -c 'cd /opt/app/python/cac_tripplanner && python3 manage.py migrate'
Building AMIs
- Configure an AWS profile with
aws configure --profile gophillygoif you haven't already - Make a production group_vars file (similarly to how is described above with development). Make sure production is set to true, and also specify an app_username, which should be set to: ubuntu
- If building the
otpmachine, make sure the latest GTFS are inotp_data, then build a graph when them in the development environment provisioning. This will result in a newGraph.objfile being written tootp_data. - Install the deployment dependencies, ideally in a virtualenv:
python3 -m venv .venv && source .venv/bin/activate && pip install -r python/cac_tripplanner/deployment_requirements.txt - Build AMIs by running (within the virtualenv):
AWS_PROFILE=gophillygo deployment/cac-stack.py create-ami - The previous command builds all AMIs. To only build a single AMI, run the same command, but also specify the
--machine-typeparameter, which may be set to one of:bastion,otp, orapp.
Launching AWS Stacks
- Copy
deployment/default_template.yamltodeployment/default.yamland edit variables - Configure an AWS profile with
aws configure --profile gophillygoif you haven't already - Create a virtualenv with the deployment dependencies if you haven't already (see Building AMIs, above).
- In the project directory, for a set of
Bluestacks in theProductionenvironment, run:AWS_PROFILE=gophillygo deployment/cac-stack.py launch-stacks --stack-color blue --stack-type prod - The previous command will do the following:
- Ensure the
VPCstack is up in Production -- it will be launched if it isn't already running - Ensure the
DataPlanestack is up in Production -- it will be launched if it isn't already running - Ensure the
OtpServerBlue stack is up in Production -- it will be launched if it isn't already running - Ensure the
WebServerBlue stack is up in Production -- it will be launched if it isn't already running
- Note that database migrations are not automatically run. When the DataPlane is first brought up, it is necessary to manually create the app user/db and run migrations.
- Launching a set of Production stacks with the other color (
Green), will use the sameVPCandDataPlanestacks, but will create differentOtpServerandWebServerstacks (if they don't already exist).
Production Blue/Green deployment
- Note which color is currently running in production. Use the opposite color in the following steps.
- Set
otp_hostin production group_vars to the CloudFront distribution with the desired color. - Run
create_amicommand to build new AMIs. - Update
default.yamlwith new AMI ids. - Run
launch_stackscommand to launch stacks with the desired color. - Test new stacks thoroughly.
- Switch the public DNS record of the site to point to the new
WebServerELB DNS. - The stacks of the previous color may be deleted when ready.