-
Notifications
You must be signed in to change notification settings - Fork 6
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
manifest consolidation for L2 PCF #294
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"db_username": "spacondev", | ||
"db_name": "spacondev", | ||
"postgis": true, | ||
"db_encoding": "UTF-8", | ||
"owner_email": "[email protected]", | ||
"owner_name": "boundless" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# build steps | ||
############# | ||
# NOTE: run the following from the root of spatialconnect-server | ||
############# | ||
# pushd web && npm install && npm run build:devio && popd | ||
# pushd server && lein uberjar && popd | ||
# if ! cf s | grep 'efc-db-test'; then cf cs pg_95_XL_DEV_SHARED_001 large-dev-100 efc-db-test -c cf/efc-db.json; fi | ||
# if ! cf S | grep 'efc-mqtt-test'; then cf cs p-rabbitmq standard efc-mqtt-test; fi | ||
# cf push | ||
############# | ||
--- | ||
applications: | ||
- name: efc-web-test | ||
# added domain due to ssl support not working on default domain | ||
domain: dev.dev.east.paas.geointservices.io | ||
buildpack: staticfile_buildpack | ||
memory: 64M | ||
instances: 1 | ||
path: ./web/public | ||
- name: efc-test | ||
# added domain due to ssl support not working on default domain | ||
domain: dev.dev.east.paas.geointservices.io | ||
buildpack: java_buildpack_offline | ||
memory: 2G | ||
instances: 1 | ||
path: ./server/target/spacon-server.jar | ||
env: | ||
ALLOWED_ORIGINS: https://efc-web-test.dev.dev.east.paas.geointservices.io | ||
AUTO_MIGRATE: true | ||
ENV: DEV | ||
KEY_STORE: /app/server/tls/test-keystore.p12 | ||
MQTT_CLIENT_ID: spacon-server-devio | ||
TRUST_STORE: /app/server/tls/test-cacerts.jks | ||
services: | ||
- efc-db-test | ||
- efc-mqtt-test |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,10 +21,31 @@ | |
[clojure.core.async :as async] | ||
[spacon.components.http.auth :refer [get-token]] | ||
[clojure.tools.logging :as log] | ||
[spacon.components.queue.protocol :as queue]) | ||
[spacon.components.queue.protocol :as queue] | ||
[clojure.data.json :as json]) | ||
(:import (org.eclipse.paho.client.mqttv3 MqttException) | ||
(java.net InetAddress))) | ||
|
||
(def vcap_mqtt | ||
"Map of keys and values from VCAP_SERVICES mqtt environment variable" | ||
(or (some-> (System/getenv "VCAP_SERVICES") | ||
(json/read-str :key-fn clojure.core/keyword) :p-rabbitmq first :credentials :protocols :mqtt) | ||
{:username :username | ||
:password :password | ||
:host :host | ||
:port :port | ||
:ssl :ssl})) | ||
|
||
(def mqtt-connect-ops | ||
"Map of authentication keys and values for mqtt connect options" | ||
{:username (or (System/getenv "MQTT_USERNAME") (:username vcap_mqtt)) | ||
:password (or (System/getenv "MQTT_PASSWORD") (:password vcap_mqtt))}) | ||
|
||
(def vcap_tcp | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe rename this to |
||
"When vcap_mqtt exists it returns a formated tcp connection" | ||
(when (some? vcap_mqtt) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems like are trying to define the url to use so this should always return a string....so I would remove this line b/c vcap_mqtt should always return the defaults that you can use to build the mqtt url. |
||
(format "%s://%s:%s" (if (:ssl vcap_mqtt) "ssl" "tcp") (:host vcap_mqtt) (:port vcap_mqtt)))) | ||
|
||
(def client-id (or (System/getenv "MQTT_CLIENT_ID") | ||
(subs (str "sc-" (InetAddress/getLocalHost)) 0 22 ))) | ||
(defonce conn (atom nil)) | ||
|
@@ -61,7 +82,7 @@ | |
(log/debugf "Connecting MQTT Client to %s" url) | ||
(try | ||
(do | ||
(reset! conn (mh/connect url client-id)) | ||
(reset! conn (mh/connect url client-id mqtt-connect-ops)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, we should allow connections to brokers that don't require any credentials. So refactor this to set credentials if they exist, otherwise connect with |
||
(log/infof "MQTT Client connected to %s" url)) | ||
(catch MqttException e | ||
(do | ||
|
@@ -82,7 +103,7 @@ | |
(async/go (async/>!! (:subscribe-channel mqtt) {:topic topic :message (msg/from-bytes message)})))) | ||
|
||
(defn reconnect [mqtt-comp reason ] | ||
(let [url (or (System/getenv "MQTT_BROKER_URL") "tcp://localhost:1883")] | ||
(let [url (or (System/getenv "MQTT_BROKER_URL") vcap_tcp "tcp://localhost:1883")] | ||
(log/debugf "Connection lost (%s). Attempting reconnect to %s" reason url) | ||
(connectmqtt url) | ||
(doall (map (fn [t] | ||
|
@@ -148,7 +169,7 @@ | |
queue/IQueue | ||
(start [this] | ||
(log/debug "Starting MQTT Component") | ||
(let [url (or (:broker-url mqtt-config) "tcp://localhost:1883") | ||
(let [url (or (:broker-url mqtt-config) vcap_tcp "tcp://localhost:1883") | ||
m (connectmqtt url) | ||
pub-chan (async/chan) | ||
sub-chan (async/chan) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if there isn't a VCAP_SERVICES environment variable, we'll want to set default mqtt options. Therefore the values in this map should represent that, ex