diff --git a/deployment/ansible/group_vars/all b/deployment/ansible/group_vars/all index 50288be16..6435e8fae 100644 --- a/deployment/ansible/group_vars/all +++ b/deployment/ansible/group_vars/all @@ -32,7 +32,7 @@ nodejs_npm_version: 2.1.17 apache_version: "2.4.7-*" -java_version: "7u111-*" +java_version: "7u121-*" graphite_carbon_version: "0.9.13-pre1" graphite_whisper_version: "0.9.13-pre1" diff --git a/deployment/ansible/roles/model-my-watershed.app/tasks/dev-and-test-dependencies.yml b/deployment/ansible/roles/model-my-watershed.app/tasks/dev-and-test-dependencies.yml index eefd0e004..b34fba7ce 100644 --- a/deployment/ansible/roles/model-my-watershed.app/tasks/dev-and-test-dependencies.yml +++ b/deployment/ansible/roles/model-my-watershed.app/tasks/dev-and-test-dependencies.yml @@ -1,6 +1,6 @@ --- - name: Install Firefox for UI tests - apt: pkg="firefox=4*" state=present + apt: pkg="firefox=5*" state=present - name: Install Xvfb for JavaScript tests apt: pkg="xvfb=2:1.15.1*" state=present diff --git a/deployment/ansible/roles/model-my-watershed.app/templates/nginx-app.conf.j2 b/deployment/ansible/roles/model-my-watershed.app/templates/nginx-app.conf.j2 index b0c1a3e1a..e502d0b31 100644 --- a/deployment/ansible/roles/model-my-watershed.app/templates/nginx-app.conf.j2 +++ b/deployment/ansible/roles/model-my-watershed.app/templates/nginx-app.conf.j2 @@ -31,7 +31,7 @@ server { location /static/ { {% if ['packer'] | is_in(group_names) -%} etag on; - expires max; + expires 1h; {% endif %} alias {{ app_static_root }}; diff --git a/deployment/ansible/roles/model-my-watershed.rwd/defaults/main.yml b/deployment/ansible/roles/model-my-watershed.rwd/defaults/main.yml index 8762677e4..78e38ac8e 100644 --- a/deployment/ansible/roles/model-my-watershed.rwd/defaults/main.yml +++ b/deployment/ansible/roles/model-my-watershed.rwd/defaults/main.yml @@ -2,4 +2,4 @@ rwd_data_path: "/opt/rwd-data" rwd_host: "localhost" rwd_port: 5000 -rwd_docker_image: "quay.io/wikiwatershed/rwd:1.0.1" +rwd_docker_image: "quay.io/wikiwatershed/rwd:1.1.1" diff --git a/deployment/ansible/roles/model-my-watershed.rwd/templates/upstart-mmw-rwd.conf.j2 b/deployment/ansible/roles/model-my-watershed.rwd/templates/upstart-mmw-rwd.conf.j2 index 2efebdcba..87371ed0b 100644 --- a/deployment/ansible/roles/model-my-watershed.rwd/templates/upstart-mmw-rwd.conf.j2 +++ b/deployment/ansible/roles/model-my-watershed.rwd/templates/upstart-mmw-rwd.conf.j2 @@ -3,7 +3,7 @@ description "Rapid Watershed Delineation" {% if ['development', 'test'] | some_are_in(group_names) -%} start on (vagrant-mounted and started docker) {% else %} -start on (filesystem and started docker) +start on (filesystem and local-filesystems and started docker) {% endif %} stop on stopping docker diff --git a/deployment/cfn/application.py b/deployment/cfn/application.py index d83d1e0d9..f22920ee4 100644 --- a/deployment/cfn/application.py +++ b/deployment/cfn/application.py @@ -48,6 +48,10 @@ class Application(StackNode): 'AppServerAutoScalingDesired': ['global:AppServerAutoScalingDesired'], 'AppServerAutoScalingMin': ['global:AppServerAutoScalingMin'], 'AppServerAutoScalingMax': ['global:AppServerAutoScalingMax'], + 'AppServerAutoScalingScheduleStartCapacity': ['global:AppServerAutoScalingScheduleStartCapacity'], # NOQA + 'AppServerAutoScalingScheduleStartRecurrence': ['global:AppServerAutoScalingScheduleStartRecurrence'], # NOQA + 'AppServerAutoScalingScheduleEndCapacity': ['global:AppServerAutoScalingScheduleEndCapacity'], # NOQA + 'AppServerAutoScalingScheduleEndRecurrence': ['global:AppServerAutoScalingScheduleEndRecurrence'], # NOQA 'SSLCertificateARN': ['global:SSLCertificateARN'], 'BackwardCompatSSLCertificateARN': ['global:BackwardCompatSSLCertificateARN'], @@ -152,6 +156,34 @@ def set_up_stack(self): Description='Application server AutoScalingGroup maximum' ), 'AppServerAutoScalingMax') + self.app_server_auto_scaling_schedule_start_recurrence = self.add_parameter( # NOQA + Parameter( + 'AppServerAutoScalingScheduleStartRecurrence', Type='String', + Default='0 13 * * 1-5', + Description='Application server ASG schedule start recurrence' + ), 'AppServerAutoScalingScheduleStartRecurrence') + + self.app_server_auto_scaling_schedule_start_capacity = self.add_parameter( # NOQA + Parameter( + 'AppServerAutoScalingScheduleStartCapacity', Type='String', + Default='1', + Description='Application server ASG schedule start capacity' + ), 'AppServerAutoScalingScheduleStartCapacity') + + self.app_server_auto_scaling_schedule_end_recurrence = self.add_parameter( # NOQA + Parameter( + 'AppServerAutoScalingScheduleEndRecurrence', Type='String', + Default='0 23 * * *', + Description='Application server ASG schedule end recurrence' + ), 'AppServerAutoScalingScheduleEndRecurrence') + + self.app_server_auto_scaling_schedule_end_capacity = self.add_parameter( # NOQA + Parameter( + 'AppServerAutoScalingScheduleEndCapacity', Type='String', + Default='1', + Description='Application server ASG schedule end capacity' + ), 'AppServerAutoScalingScheduleEndCapacity') + self.ssl_certificate_arn = self.add_parameter(Parameter( 'SSLCertificateARN', Type='String', Description='ARN for a SSL certificate stored in IAM' @@ -395,7 +427,7 @@ def create_auto_scaling_resources(self, app_server_security_group, self.blue_tile_distribution_endpoint))) )) - self.add_resource( + blue_app_server_asg = self.add_resource( asg.AutoScalingGroup( 'asgAppServerBlue', AvailabilityZones=Ref(self.availability_zones), @@ -424,6 +456,30 @@ def create_auto_scaling_resources(self, app_server_security_group, Tags=[asg.Tag('Name', 'AppServer', True)]) ) + self.add_resource( + asg.ScheduledAction( + 'schedTileServerAutoScalingStartBlue', + AutoScalingGroupName=Ref(blue_app_server_asg), + Condition='BlueCondition', + DesiredCapacity=Ref( + self.app_server_auto_scaling_schedule_start_capacity), + Recurrence=Ref( + self.app_server_auto_scaling_schedule_start_recurrence) + ) + ) + + self.add_resource( + asg.ScheduledAction( + 'schedTileServerAutoScalingEndBlue', + AutoScalingGroupName=Ref(blue_app_server_asg), + Condition='BlueCondition', + DesiredCapacity=Ref( + self.app_server_auto_scaling_schedule_end_capacity), + Recurrence=Ref( + self.app_server_auto_scaling_schedule_end_recurrence) + ) + ) + green_app_server_launch_config = self.add_resource( asg.LaunchConfiguration( 'lcAppServerGreen', @@ -438,7 +494,7 @@ def create_auto_scaling_resources(self, app_server_security_group, self.green_tile_distribution_endpoint))) )) - self.add_resource( + green_app_server_asg = self.add_resource( asg.AutoScalingGroup( 'asgAppServerGreen', AvailabilityZones=Ref(self.availability_zones), @@ -467,6 +523,30 @@ def create_auto_scaling_resources(self, app_server_security_group, Tags=[asg.Tag('Name', 'AppServer', True)]) ) + self.add_resource( + asg.ScheduledAction( + 'schedTileServerAutoScalingStartGreen', + AutoScalingGroupName=Ref(green_app_server_asg), + Condition='GreenCondition', + DesiredCapacity=Ref( + self.app_server_auto_scaling_schedule_start_capacity), + Recurrence=Ref( + self.app_server_auto_scaling_schedule_start_recurrence) + ) + ) + + self.add_resource( + asg.ScheduledAction( + 'schedTileServerAutoScalingEndGreen', + AutoScalingGroupName=Ref(green_app_server_asg), + Condition='GreenCondition', + DesiredCapacity=Ref( + self.app_server_auto_scaling_schedule_end_capacity), + Recurrence=Ref( + self.app_server_auto_scaling_schedule_end_recurrence) + ) + ) + def get_cloud_config(self, tile_distribution_endpoint): return ['#cloud-config\n', '\n', diff --git a/deployment/cfn/tiler.py b/deployment/cfn/tiler.py index e0ad6bccd..97a068f88 100644 --- a/deployment/cfn/tiler.py +++ b/deployment/cfn/tiler.py @@ -49,6 +49,10 @@ class Tiler(StackNode): 'TileServerAutoScalingDesired': ['global:TileServerAutoScalingDesired'], # NOQA 'TileServerAutoScalingMin': ['global:TileServerAutoScalingMin'], 'TileServerAutoScalingMax': ['global:TileServerAutoScalingMax'], + 'TileServerAutoScalingScheduleStartCapacity': ['global:TileServerAutoScalingScheduleStartCapacity'], # NOQA + 'TileServerAutoScalingScheduleStartRecurrence': ['global:TileServerAutoScalingScheduleStartRecurrence'], # NOQA + 'TileServerAutoScalingScheduleEndCapacity': ['global:TileServerAutoScalingScheduleEndCapacity'], # NOQA + 'TileServerAutoScalingScheduleEndRecurrence': ['global:TileServerAutoScalingScheduleEndRecurrence'], # NOQA 'SSLCertificateARN': ['global:SSLCertificateARN'], 'PublicSubnets': ['global:PublicSubnets', 'VPC:PublicSubnets'], 'PrivateSubnets': ['global:PrivateSubnets', 'VPC:PrivateSubnets'], @@ -143,6 +147,34 @@ def set_up_stack(self): Description='Tile server AutoScalingGroup maximum' ), 'TileServerAutoScalingMax') + self.tile_server_auto_scaling_schedule_start_recurrence = self.add_parameter( # NOQA + Parameter( + 'TileServerAutoScalingScheduleStartRecurrence', Type='String', + Default='0 13 * * 1-5', + Description='Tile server ASG schedule start recurrence' + ), 'TileServerAutoScalingScheduleStartRecurrence') + + self.tile_server_auto_scaling_schedule_start_capacity = self.add_parameter( # NOQA + Parameter( + 'TileServerAutoScalingScheduleStartCapacity', Type='String', + Default='1', + Description='Tile server ASG schedule start capacity' + ), 'TileServerAutoScalingScheduleStartCapacity') + + self.tile_server_auto_scaling_schedule_end_recurrence = self.add_parameter( # NOQA + Parameter( + 'TileServerAutoScalingScheduleEndRecurrence', Type='String', + Default='0 23 * * *', + Description='Tile server ASG schedule end recurrence' + ), 'TileServerAutoScalingScheduleEndRecurrence') + + self.tile_server_auto_scaling_schedule_end_capacity = self.add_parameter( # NOQA + Parameter( + 'TileServerAutoScalingScheduleEndCapacity', Type='String', + Default='1', + Description='Tile server ASG schedule end capacity' + ), 'TileServerAutoScalingScheduleEndCapacity') + self.ssl_certificate_arn = self.add_parameter(Parameter( 'SSLCertificateARN', Type='String', Description='ARN for a SSL certificate stored in IAM' @@ -318,7 +350,7 @@ def create_auto_scaling_resources(self, tile_server_security_group, tile_server_auto_scaling_group_name = 'asgTileServer' - self.add_resource( + tile_server_asg = self.add_resource( asg.AutoScalingGroup( tile_server_auto_scaling_group_name, AvailabilityZones=Ref(self.availability_zones), @@ -346,6 +378,28 @@ def create_auto_scaling_resources(self, tile_server_security_group, ) ) + self.add_resource( + asg.ScheduledAction( + 'schedTileServerAutoScalingStart', + AutoScalingGroupName=Ref(tile_server_asg), + DesiredCapacity=Ref( + self.tile_server_auto_scaling_schedule_start_capacity), + Recurrence=Ref( + self.tile_server_auto_scaling_schedule_start_recurrence) + ) + ) + + self.add_resource( + asg.ScheduledAction( + 'schedTileServerAutoScalingEnd', + AutoScalingGroupName=Ref(tile_server_asg), + DesiredCapacity=Ref( + self.tile_server_auto_scaling_schedule_end_capacity), + Recurrence=Ref( + self.tile_server_auto_scaling_schedule_end_recurrence) + ) + ) + def get_cloud_config(self): return ['#cloud-config\n', '\n', diff --git a/deployment/cfn/worker.py b/deployment/cfn/worker.py index aa5e4c9a8..dff482f1f 100644 --- a/deployment/cfn/worker.py +++ b/deployment/cfn/worker.py @@ -50,6 +50,10 @@ class Worker(StackNode): 'WorkerAutoScalingDesired': ['global:WorkerAutoScalingDesired'], # NOQA 'WorkerAutoScalingMin': ['global:WorkerAutoScalingMin'], 'WorkerAutoScalingMax': ['global:WorkerAutoScalingMax'], + 'WorkerAutoScalingScheduleStartCapacity': ['global:WorkerAutoScalingScheduleStartCapacity'], # NOQA + 'WorkerAutoScalingScheduleStartRecurrence': ['global:WorkerAutoScalingScheduleStartRecurrence'], # NOQA + 'WorkerAutoScalingScheduleEndCapacity': ['global:WorkerAutoScalingScheduleEndCapacity'], # NOQA + 'WorkerAutoScalingScheduleEndRecurrence': ['global:WorkerAutoScalingScheduleEndRecurrence'], # NOQA 'PublicSubnets': ['global:PublicSubnets', 'VPC:PublicSubnets'], 'PrivateSubnets': ['global:PrivateSubnets', 'VPC:PrivateSubnets'], 'PublicHostedZoneName': ['global:PublicHostedZoneName'], @@ -135,20 +139,48 @@ def set_up_stack(self): ), 'WorkerInstanceProfile') self.worker_auto_scaling_desired = self.add_parameter(Parameter( - 'WorkerAutoScalingDesired', Type='String', Default='1', + 'WorkerAutoScalingDesired', Type='String', Default='2', Description='Worker AutoScalingGroup desired' ), 'WorkerAutoScalingDesired') self.worker_auto_scaling_min = self.add_parameter(Parameter( - 'WorkerAutoScalingMin', Type='String', Default='1', + 'WorkerAutoScalingMin', Type='String', Default='0', Description='Worker AutoScalingGroup minimum' ), 'WorkerAutoScalingMin') self.worker_auto_scaling_max = self.add_parameter(Parameter( - 'WorkerAutoScalingMax', Type='String', Default='1', + 'WorkerAutoScalingMax', Type='String', Default='2', Description='Worker AutoScalingGroup maximum' ), 'WorkerAutoScalingMax') + self.worker_auto_scaling_schedule_start_recurrence = self.add_parameter( # NOQA + Parameter( + 'WorkerAutoScalingScheduleStartRecurrence', Type='String', + Default='0 13 * * 1-5', + Description='Worker ASG schedule start recurrence' + ), 'WorkerAutoScalingScheduleStartRecurrence') + + self.worker_auto_scaling_schedule_start_capacity = self.add_parameter( # NOQA + Parameter( + 'WorkerAutoScalingScheduleStartCapacity', Type='String', + Default='2', + Description='Worker ASG schedule start capacity' + ), 'WorkerAutoScalingScheduleStartCapacity') + + self.worker_auto_scaling_schedule_end_recurrence = self.add_parameter( # NOQA + Parameter( + 'WorkerAutoScalingScheduleEndRecurrence', Type='String', + Default='0 23 * * *', + Description='Worker ASG schedule end recurrence' + ), 'WorkerAutoScalingScheduleEndRecurrence') + + self.worker_auto_scaling_schedule_end_capacity = self.add_parameter( # NOQA + Parameter( + 'WorkerAutoScalingScheduleEndCapacity', Type='String', + Default='0', + Description='Worker ASG schedule end capacity' + ), 'WorkerAutoScalingScheduleEndCapacity') + self.public_subnets = self.add_parameter(Parameter( 'PublicSubnets', Type='CommaDelimitedList', Description='A list of public subnets' @@ -310,7 +342,7 @@ def create_auto_scaling_resources(self, worker_security_group, worker_lb): worker_auto_scaling_group_name = 'asgWorker' - return self.add_resource( + worker_asg = self.add_resource( asg.AutoScalingGroup( worker_auto_scaling_group_name, AvailabilityZones=Ref(self.availability_zones), @@ -338,6 +370,30 @@ def create_auto_scaling_resources(self, worker_security_group, worker_lb): ) ) + self.add_resource( + asg.ScheduledAction( + 'schedWorkerAutoScalingStart', + AutoScalingGroupName=Ref(worker_asg), + DesiredCapacity=Ref( + self.worker_auto_scaling_schedule_start_capacity), + Recurrence=Ref( + self.worker_auto_scaling_schedule_start_recurrence) + ) + ) + + self.add_resource( + asg.ScheduledAction( + 'schedWorkerAutoScalingEnd', + AutoScalingGroupName=Ref(worker_asg), + DesiredCapacity=Ref( + self.worker_auto_scaling_schedule_end_capacity), + Recurrence=Ref( + self.worker_auto_scaling_schedule_end_recurrence) + ) + ) + + return worker_asg + def get_cloud_config(self): return ['#cloud-config\n', '\n', diff --git a/deployment/default.yml.example b/deployment/default.yml.example index be82e2d9b..a9924aca5 100644 --- a/deployment/default.yml.example +++ b/deployment/default.yml.example @@ -23,8 +23,14 @@ AppServerInstanceType: 't2.micro' #AppServerAMI: '' AppServerInstanceProfile: 'AppServerInstanceProfile' AppServerAutoScalingDesired: '1' -AppServerAutoScalingMin: '1' +AppServerAutoScalingMin: '0' AppServerAutoScalingMax: '1' +AppServerAutoScalingScheduleStartCapacity: '1' +# 8AM ET +AppServerAutoScalingScheduleStartRecurrence: '0 13 * * 1-5' +AppServerAutoScalingScheduleEndCapacity: '0' +# 6PM ET +AppServerAutoScalingScheduleEndRecurrence: '0 23 * * *' SSLCertificateARN: 'arn:aws:iam...' BackwardCompatSSLCertificateARN: 'arn:aws:iam...' TileServerInstanceType: 't2.micro' @@ -33,16 +39,28 @@ TileServerInstanceType: 't2.micro' #TileServerAMI: '' TileServerInstanceProfile: 'TileServerInstanceProfile' TileServerAutoScalingDesired: '1' -TileServerAutoScalingMin: '1' +TileServerAutoScalingMin: '0' TileServerAutoScalingMax: '1' +TileServerAutoScalingScheduleStartCapacity: '1' +# 8AM ET +TileServerAutoScalingScheduleStartRecurrence: '0 13 * * 1-5' +TileServerAutoScalingScheduleEndCapacity: '0' +# 6PM ET +TileServerAutoScalingScheduleEndRecurrence: '0 23 * * *' WorkerInstanceType: 't2.micro' # Leaving this commented dynamically looks up the # most recent AMI for this type. #WorkerAMI: '' WorkerInstanceProfile: 'WorkerInstanceProfile' -WorkerAutoScalingDesired: '1' -WorkerAutoScalingMin: '1' -WorkerAutoScalingMax: '1' +WorkerAutoScalingDesired: '2' +WorkerAutoScalingMin: '0' +WorkerAutoScalingMax: '2' +WorkerAutoScalingScheduleStartCapacity: '2' +# 8AM ET +WorkerAutoScalingScheduleStartRecurrence: '0 13 * * 1-5' +WorkerAutoScalingScheduleEndCapacity: '0' +# 6PM ET +WorkerAutoScalingScheduleEndRecurrence: '0 23 * * *' ITSIBaseURL: '' ITSISecretKey: '' RollbarServerSideAccessToken: '' diff --git a/deployment/packer/template.js b/deployment/packer/template.js index a18ed7230..e7feeb50d 100644 --- a/deployment/packer/template.js +++ b/deployment/packer/template.js @@ -63,7 +63,7 @@ "ami_block_device_mappings": [ { "device_name": "/dev/sdf", - "snapshot_id": "snap-4a764b4a", + "snapshot_id": "snap-090ac799996dba0a4", "volume_type": "gp2", "delete_on_termination": true } diff --git a/scripts/aws/setupdb.sh b/scripts/aws/setupdb.sh index eb322ead9..000bbe908 100755 --- a/scripts/aws/setupdb.sh +++ b/scripts/aws/setupdb.sh @@ -84,7 +84,7 @@ fi if [ "$load_dep" = "true" ] ; then # Fetch DEP layers FILES=("dep_urban_areas.sql.gz" "dep_municipalities.sql.gz") - PATHS=("dep_urbanareas" "dep_municipalities") + PATHS=("urban_areas" "municipalities") download_and_load $FILES purge_tile_cache $PATHS diff --git a/src/mmw/apps/core/templates/base.html b/src/mmw/apps/core/templates/base.html index 2e796ef2d..344752258 100644 --- a/src/mmw/apps/core/templates/base.html +++ b/src/mmw/apps/core/templates/base.html @@ -1,3 +1,4 @@ +{% include 'head.html' %} {% load staticfiles %} @@ -21,6 +22,7 @@ ga('create', '{{ GOOGLE_ANALYTICS_ACCOUNT }}', 'auto'); ga('send', 'pageview'); + window.ga = ga; diff --git a/src/mmw/apps/core/templates/head.html b/src/mmw/apps/core/templates/head.html new file mode 100644 index 000000000..65575d8f8 --- /dev/null +++ b/src/mmw/apps/core/templates/head.html @@ -0,0 +1,25 @@ +{% load staticfiles %} + + + +
+ {% block metatitle %} +