Skip to content

triberraar/triber-sensor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

triber-sensor

Development

Travis status Coveralls status Codecov status Coverity scan status Codacy code quality

Master

Travis status Coveralls status Codecov status Codacy code quality

Used technologies

This application is build upon Spring boot. It uses a mysql database (in memory or persistent), an elasticsearch cluster and optional mqtt. Other parts of Spring boot are used as well (eg liquibase, hibernate, jackson, integration, ...).

Configuration

The configuration uses Spring boot as well. So all configuration can be overridden in the Spring boot way (config file, command line arguments, ...). For the general properties have a look at the application.properties file.

Profiles

MQTT

The profile 'MQTT' activates this application as an mqtt client. A broker has to be running for this. The default connection configuration for the broker is:

  • mqtt.broker.ip=localhost
  • mqtt.broker.port=1883

dev

The profile 'dev' activates the MQTT profile. It also uses the H2 database (stored in ~/triberSensor) and drops and reinitiates the whole database (using liquibase). After this it populates the database with some test data. This is the profile that should be used during development

test

This profile is used during the integration tests. It clears the elasticsearch cluster.

Run with docker

To make the docker image, be sure to have docker tools installed and then run:

mvn clean package docker:build

To run the image use

docker run --name triber-sensor -d -p 8080:8080 triberraar/triber-sensor

This will run the application with an embedded elasticsearch and embedded H2 database. It is also possible to run this in combination with a docker container running elasticsearch and a docker container running mysql. Just use Docker compose by saying docker-compose up Unless you want to launch everything seperate (eg to run different containers on different machines):

###x86 image size layers

start a mysql container
docker run --name triber-sensor-db -e MYSQL_ROOT_PASSWORD=<root> -e MYSQL_DATABASE=triber-sensor -e MYSQL_USER=<user> -e MYSQL_PASSWORD=<password> -d -p 3306:3306 mysql:latest
start an elasticsearch container
docker run --name triber-sensor-elastic -d -p 9200:9200 -p 9300:9300 elasticsearch:1.7.3
start the application container
docker run --name triber-sensor -d -p 8080:8080 -e SPRING_DATASOURCE_URL=jdbc:mysql://<ip of docker host>:3306/triber-sensor -e SPRING_DATASOURCE_USERNAME=<user> -e SPRING_DATASOURCE_PASSWORD=<password> -e SPRING_DATA_ELASTICSEARCH_CLUSTER-NODES=<ip of docker host>:9300 -e SPRING_DATA_ELASTICSEARCH_PROPERTIES_NODE_LOCAL=false -e SPRING_DATA_ELASTICSEARCH_PROPERTIES_NODE_DATA=false -e SPRING_DATA_ELASTICSEARCH_NODE_CLIENT=true triberraar/triber-sensor
start the application container with docker container linking
docker run --name triber-sensor --link triber-sensor-db --link triber-sensor-elastic -d -p 8080:8080 -e SPRING_DATASOURCE_URL=jdbc:mysql://triber-sensor-db:3306/triber-sensor -e SPRING_DATASOURCE_USERNAME=<user> -e SPRING_DATASOURCE_PASSWORD=<password> -e SPRING_DATA_ELASTICSEARCH_CLUSTER-NODES=triber-sensor-elastic:9300 -e SPRING_DATA_ELASTICSEARCH_PROPERTIES_NODE_LOCAL=false -e SPRING_DATA_ELASTICSEARCH_PROPERTIES_NODE_DATA=false -e SPRING_DATA_ELASTICSEARCH_NODE_CLIENT=true triberraar/triber-sensor

###Raspberry pi image size layers

Use a datadirectory (eg /triber-sensor/data/elastic)

start a mysql container
docker run --name triber-sensor-db -e MYSQL_ROOT_PASSWORD=<root> -e MYSQL_DATABASE=triber-sensor -e MYSQL_USER=<user> -e MYSQL_PASSWORD=<password> -d -p 3306:3306 -v <data-directory>:/var/lib/mysql hypriot/rpi-mysql:latest
start an elasticsearch container
docker run --name triber-sensor-elastic -d -p 9200:9200 -p 9300:9300 -v <data-directory>:/data rpidockers/elasticsearch:1.7.1
start application
docker run --name triber-sensor -d -p 8080:8080 triberraar/rpi-triber-sensor
start a mqtt broker
docker run --name mosca -d -p 1883:1883 triberraar/rpi-mosca

###Configuration If you follow the docker way and have a docker for each service, you have to pass certain configuration to docker. This can be done with linking, if the docker containers run on the same host. Pass following properties with the -e flag (-e NAME=VALUE):

  • SPRING_DATASOURCE_URL (corresponds to spring.datasource.url): jdbc:mysql://:<port of mysql host (usually 3306)>/triber-sensor
  • SPRING_DATASOURCE_USERNAME (corresponds to spring.datasource.username)
  • SPRING_DATASOURCE_PASSWORD (corresponds to spring.datasource.password)
  • SPRING_DATA_ELASTICSEARCH_CLUSTER-NODES (corresponds to spring.data.elasticsearch.cluster-NODES): :<port of elasticsearch (usually 9300)>
  • SPRING_DATA_ELASTICSEARCH_PROPERTIES_NODE_LOCAL (corresponds to spring.data.elasticsearch.properties.node.local): should be false
  • SPRING_DATA_ELASTICSEARCH_PROPERTIES_NODE_DATA (corresponds to spring.data.elasticsearch.properties.node.data): should be false
  • SPRING_DATA_ELASTICSEARCH_NODE_CLIENT (corresponds to spring.data.elasticsearch.node.client): should be true
  • MQTT_BROKER_IP (corresponds to mqtt.broker.ip): ip of the mqtt broker
  • MQTT_BROKER_PORT (corresponds to mqtt.broker.port): port of the mqtt broker

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages