Skip to content

Latest commit

 

History

History
37 lines (23 loc) · 2.76 KB

File metadata and controls

37 lines (23 loc) · 2.76 KB

SmartIOT.Connector.App

This project implements a simple SmartIOT.Connector runner able to run a SmartIOT.Connector instance as a console application.

The main program takes a json configuration file as parameter, or uses the default ./smartiot-config.json if none is provided. See this file for a sample configuration. Please note that the internal "Configuration" element reflects the Core SmartIOT.Connector configuration (see here) The sample configuration will log to the console and to daily rolling file smartiot-connector.log. You can change the logging file from json configuration. The underlying logging library is Serilog, so you can customize the outputTemplate to be used too.

Docker support

The Console runner can also be run on Docker. You just need to map a volume pointing the configuration folder /SmartIOT.Connector and expose the ports needed for external communications.
The container image will look for configuration file at /SmartIOT.Connector/smartiot-config.json

A prebuilt Docker image is also available on Docker Hub. Use the following command to pull the latest image, or browse https://hub.docker.com/repository/docker/lucadomenichini/smartiot-connector-app for available tags.

docker pull lucadomenichini/smartiot-connector-app:latest

Building the Docker image from source

Provided you installed docker on your machine, go to SmartIOT.Connector root project folder and type:

docker build -t smartiot-connector -f Apps/SmartIOT.Connector.App/Dockerfile .

Running the container

To run the container you need to provide the volume where the runner will search the smartiot-config.json configuration file. By default, the container will look for /SmartIOT.Connector/smartiot-config.json file.

You will also need to expose the ports where the communications with external containers happens. Suppose you are running a Mqtt Server inside the container on port 1883, and exposing Prometheus metrics on port 9001 (as per sample configuration file)

Type this to run the container and expose ports on the host machine:

docker run -it --rm -v /path/to/smartiot-connector/configuration/folder:/SmartIOT.Connector -p 9001:9001 -p 1883:1883 smartiot-connector

Suppose you have downloaded the solution on Windows on folder C:\develop\SmartIOT.Connector. You will have an smartiot-config.json file under the SmartIOT.Connector.App project folder.
Type this to use that configuration file:

docker run -it --rm -v C:\develop\SmartIOT.Connector\Apps\SmartIOT.Connector.App:/SmartIOT.Connector -p 9001:9001 -p 1883:1883 smartiot-connector