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

Update map #3

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions national-parks/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
results/
9 changes: 9 additions & 0 deletions national-parks/habitat/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Habitat package: national-parks

## Description

Provide a brief description of the `national-parks` plan / purpose.

## Usage

Describe the general usage for the `national-parks` plan
6 changes: 6 additions & 0 deletions national-parks/habitat/default.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
mongodb_database = "demo"

[server]
port = "8080"
shutdown-port = "8005"
redirect-port = "8443"
15 changes: 15 additions & 0 deletions national-parks/habitat/haproxy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
maxconn = 32
httpchk = 'GET /national-parks'

[front-end]
listen = '*'
port = 8085
mode = 'http'

[status]
enabled = true
listen = '*'
port = 8000
user = 'admin'
password = 'password'
uri = '/haproxy-stats'
21 changes: 21 additions & 0 deletions national-parks/habitat/hooks/init
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash -x

echo "Preparing TOMCAT_HOME..."
# Move directories that ship in the package into place
cp -a {{pkgPathFor "core/tomcat8"}}/tc {{pkg.svc_var_path}}/

cp {{pkg.path}}/*.war {{pkg.svc_var_path}}/tc/webapps

# Following lines are to copy project tomcat configs to run time tomcat8 directory
for file in $(cd {{pkg.svc_config_path}}; ls -1 *.xml)
do
echo "Linking $file"
target="${file//_//}"
ln -vsf {{pkg.svc_config_path}}/$file {{pkg.svc_var_path}}/tc/$target
done

echo "Done preparing TOMCAT_HOME"

{{#if bind.database ~}}
{{pkgPathFor "core/mongo-tools"}}/bin/mongoimport --drop -d demo -c nationalparks --type json --jsonArray --file {{pkg.path}}/national-parks.json --host={{bind.database.first.sys.ip}} --port={{bind.database.first.cfg.port}}
{{/if ~}}
12 changes: 12 additions & 0 deletions national-parks/habitat/hooks/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

{{#if bind.database ~}}
export CATALINA_OPTS="-DMONGODB_SERVICE_HOST={{bind.database.first.sys.ip}}
-DMONGODB_SERVICE_PORT={{bind.database.first.cfg.port}}
-DMONGODB_DATABASE={{cfg.mongodb_database}}"
{{/if ~}}

export JAVA_HOME="{{pkgPathFor "core/jre8"}}"
export TOMCAT_HOME="{{pkgPathFor "core/tomcat8"}}/tc"
cp {{pkg.path}}/*.war $TOMCAT_HOME/webapps
exec ${TOMCAT_HOME}/bin/catalina.sh run
7 changes: 7 additions & 0 deletions national-parks/habitat/mongo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[mongod]

[mongod.net]
bind_ip = "0.0.0.0"

[mongod.security]
cluster_auth_mode = ""
34 changes: 34 additions & 0 deletions national-parks/habitat/plan.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
pkg_origin=weldfire_hab_demo
pkg_name=national-parks
pkg_description="A sample JavaEE Web app deployed in the Tomcat8 package"
pkg_version=1.1.0
pkg_maintainer="Bill Meyer <b@chef.io>"
pkg_license=('Apache-2.0')
pkg_deps=(core/tomcat8 core/jre8 core/mongo-tools)
pkg_build_deps=(core/jdk8/8u131 core/maven)
pkg_svc_user="root"
pkg_binds=(
[database]="port"
)
pkg_exports=(
[port]=server.port
)
pkg_exposes=(port)

do_prepare()
{
export JAVA_HOME=$(hab pkg path core/jdk8)
}

do_build()
{
cp -r $PLAN_CONTEXT/../ $HAB_CACHE_SRC_PATH/$pkg_dirname
cd ${HAB_CACHE_SRC_PATH}/${pkg_dirname}
mvn package
}

do_install()
{
cp ${HAB_CACHE_SRC_PATH}/${pkg_dirname}/target/${pkg_name}.war ${PREFIX}/
cp -v ${HAB_CACHE_SRC_PATH}/${pkg_dirname}/data/national-parks.json ${PREFIX}/
}
14 changes: 8 additions & 6 deletions national-parks/src/main/webapp/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<title>Map of National Parks</title>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.0.3/dist/leaflet.css"/>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.1/dist/leaflet.css" integrity="sha512-Rksm5RenBEKSKFjgI3a41vrjkw4EVPlJ3+OiI65vTjIdo9brlAacEuKOiQ5OFh7cOI1bkDwLqdLw3Zg0cRJAAQ==" crossorigin=""/>
<script src="https://code.jquery.com/jquery-2.0.0.min.js"></script>
<link href='https://fonts.googleapis.com/css?family=Oswald' rel='stylesheet' type='text/css'>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
Expand Down Expand Up @@ -35,20 +35,22 @@

</head>
<body>
<h1 id="title">U.S. National Parks v6.3</h1>
<h1 id="title">U.S. National Parks v6.4.0</h1>

<div id="map"></div>
<script src="https://unpkg.com/leaflet@1.0.3/dist/leaflet.js"></script>
<script src="https://unpkg.com/leaflet@1.3.1/dist/leaflet.js" integrity="sha512-/Nsx9X4HebavoBvEBuyp3I7od5tA0UzAxs+j83KgC8PU0kgB4XiK4Lfe4y4cgBtaRJQEIFCW+oC506aPT2L1zw==" crossorigin=""></script>
<script type="text/coffeescript" src="scripts/sprite.coffee"></script>
<script type="text/coffeescript" src "script.coffee"></script>
<script>
center = new L.LatLng(39.82, -98.57);
zoom = 5;

var map = L.map('map').setView(center, zoom);
var markerLayerGroup = L.layerGroup().addTo(map);

L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
L.tileLayer('https://{s}.tile.thunderforest.com/landscape/{z}/{x}/{y}.png?apikey=816f897a456b4595a09bf8e1d42cfa0b', {
maxZoom: 18,
attribution: 'Map data &copy; <a href="https://openstreetmap.org">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>'
attribution: 'Maps © <a href="http://www.thunderforest.com">Thunderforest</a>, Data © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap contributors</a>'
}).addTo(map);

function getPins(e) {
Expand Down Expand Up @@ -79,7 +81,7 @@ <h1 id="title">U.S. National Parks v6.3</h1>
nationalPark.zipCode + "</br>";

markerArray[i] = L.marker(
[nationalPark.location.coordinates[1], nationalPark.location.coordinates[0]]).bindPopup(popupInformation);
[nationalPark.location.coordinates[1], nationalPark.location.coordinates[0]], { icon: L.icon({ iconUrl: 'images/redicon.png', iconAnchor: [12.5,40]}) }).bindPopup(popupInformation);
}

markerLayerGroup = L.layerGroup(markerArray).addTo(map);
Expand Down