Skip to content

Commit

Permalink
[Transferring] Added Source code of Ghost Emulator complete (v1.0)
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio Defina committed Feb 20, 2020
1 parent dd3d55b commit dac3eb6
Show file tree
Hide file tree
Showing 93 changed files with 6,578 additions and 2 deletions.
33 changes: 33 additions & 0 deletions .env.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

ENVTYPE=dev

MQTT_QUEUE_PORT=1884
MQTT_DIAGNOSTIC_PORT=9002

REDIS_PORT=6380

WEB_GOST_PORT=8001
WEB_DIAGNOSTIC_PORT=3002


#Mosquitto
MOSQUITTO_USERNAME_VALUE=mosquitto
MOSQUITTO_PASSWORD_VALUE=mosquitto
MOSQUITTO_CLIENT_ID_VALUE=GOST_MQTT_EMULATOR

#RabbitMQ config
RABBITMQ_USER=monica
RABBITMQ_PASS=monica123
RABBITMQ_EXPOSED_PORT=5673
RABBITMQ_EXPOSED_PORT_DIAGNOSTIC=15673


REDISCACHE_PORT=6379

SUBNET_BASE_ADDRESS=172.19.4.0
SUBNET_BASE_NUMBERELEMENTS=16

V_LOCALHOST_MACHINE=192.168.2.3

GOST_THINGID_SFN_VALUE=1
GOST_THINGID_WRISTBANDS_VALUE=2
33 changes: 33 additions & 0 deletions .env.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

ENVTYPE=local

MQTT_QUEUE_PORT=1884
MQTT_DIAGNOSTIC_PORT=9002

REDIS_PORT=6380

WEB_GOST_PORT=8001
WEB_DIAGNOSTIC_PORT=3002


#Mosquitto
MOSQUITTO_USERNAME_VALUE=mosquitto
MOSQUITTO_PASSWORD_VALUE=mosquitto
MOSQUITTO_CLIENT_ID_VALUE=GOST_MQTT_EMULATOR

#RabbitMQ config
RABBITMQ_USER=monica
RABBITMQ_PASS=monica123
RABBITMQ_EXPOSED_PORT=5673
RABBITMQ_EXPOSED_PORT_DIAGNOSTIC=15673


REDISCACHE_PORT=6379

SUBNET_BASE_ADDRESS=172.19.4.0
SUBNET_BASE_NUMBERELEMENTS=16

V_LOCALHOST_MACHINE=192.168.2.3

GOST_THINGID_SFN_VALUE=1
GOST_THINGID_WRISTBANDS_VALUE=2
33 changes: 33 additions & 0 deletions .env.prod
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

ENVTYPE=prod

MQTT_QUEUE_PORT=1884
MQTT_DIAGNOSTIC_PORT=9002

REDIS_PORT=6380

WEB_GOST_PORT=8001
WEB_DIAGNOSTIC_PORT=3002


#Mosquitto
MOSQUITTO_USERNAME_VALUE=mosquitto
MOSQUITTO_PASSWORD_VALUE=mosquitto
MOSQUITTO_CLIENT_ID_VALUE=GOST_MQTT_EMULATOR

#RabbitMQ config
RABBITMQ_USER=monica
RABBITMQ_PASS=monica123
RABBITMQ_EXPOSED_PORT=5673
RABBITMQ_EXPOSED_PORT_DIAGNOSTIC=15673


REDISCACHE_PORT=6379

SUBNET_BASE_ADDRESS=172.19.4.0
SUBNET_BASE_NUMBERELEMENTS=16

V_LOCALHOST_MACHINE=192.168.2.3

GOST_THINGID_SFN_VALUE=1
GOST_THINGID_WRISTBANDS_VALUE=2
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.project
.env
.idea
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# GhostSCRALMQTTEmulator
Solution that can be used to emulate GHOST Catalog and MQTT Observations received from the field
# GOSTDockerMQTTEmulator

119 changes: 119 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
version: '3.7'

services:
mqtt:
container_name: gostemul_docker_mqtt_${ENVTYPE}
hostname: gostemul_host_mqtt
image: ansi/mosquitto:latest
networks:
- gostemul_docker_network
ports:
- '${MQTT_QUEUE_PORT}:1883'
- '${MQTT_DIAGNOSTIC_PORT}:9001'
expose:
- "${MQTT_QUEUE_PORT}"
- "${MQTT_DIAGNOSTIC_PORT}"
entrypoint: /usr/local/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf
environment:
- MOSQUITTO_MQTT_URL=mqtt
- MOSQUITTO_USERNAME=${MOSQUITTO_USERNAME_VALUE}
- MOSQUITTO_PASSWORD=${MOSQUITTO_PASSWORD_VALUE}
volumes:
- ./images/mosquitto:/etc/mosquitto:ro
- ./images/mosquitto/auth:/etc/mosquitto/auth
- ./images/mosquitto/logs:/var/log/mosquitto:rw
- ./images/mosquitto/data:/mosquitto/data/

# RabbitMQ
rabbit:
container_name: gostemul_docker_rabbit_${ENVTYPE}
hostname: gostemul_host_rabbit_${ENVTYPE}
image: rabbitmq:latest
networks:
- gostemul_docker_network
environment:
- RABBITMQ_DEFAULT_USER=${RABBITMQ_USER}
- RABBITMQ_DEFAULT_PASS=${RABBITMQ_PASS}
- RABBITMQ_DEFAULT_VHOST=/
- RABBITMQ_LOG_BASE=/var/log/rabbitmq
- RABBITMQ_HOSTNAME=rabbit
ports:
- "${RABBITMQ_EXPOSED_PORT}:5672" # we forward this port because it's useful for debugging
- "${RABBITMQ_EXPOSED_PORT_DIAGNOSTIC}:15672" # hre, we can access rabbitmq management plugin

redis:
container_name: gostemul_docker_redis_${ENVTYPE}
hostname: gostemul_host_redis_${ENVTYPE}
image: redis:latest
sysctls:
net.core.somaxconn: 1024
ports:
- '${REDIS_PORT}:6379'
networks:
- gostemul_docker_network

#Celery worker
worker:
container_name: gostemul_docker_celery_worker
hostname: gostemul_host_celery_worker
volumes:
- .:/code
build:
context: .
dockerfile: images/worker_celery/Dockerfile
command: images/worker_celery/celery_entrypoint.sh
networks:
- gostemul_docker_network
environment:
- MQTT_BROKER_IP_ADDRESS=mqtt
- MQTT_BROKER_USERNAME=${MOSQUITTO_USERNAME_VALUE}
- MQTT_BROKER_PASSWORD=${MOSQUITTO_PASSWORD_VALUE}
- MQTT_BROKER_CLIENTID=${MOSQUITTO_CLIENT_ID_VALUE}
- DJANGO_SETTINGS_MODULE=shared.settings.appglobalconf
- RABBITMQ_DEFAULT_USER=${RABBITMQ_USER}
- RABBITMQ_DEFAULT_PASS=${RABBITMQ_PASS}
- RABBITMQ_HOSTNAME=rabbit
- CACHEREDIS_DEFAULT_HOSTNAME=redis
- CACHEREDIS_DEFAULT_PORT=6379
- GOST_THINGID_SFN=${GOST_THINGID_SFN_VALUE}
- GOST_THINGID_WRISTBAND=${GOST_THINGID_WRISTBANDS_VALUE}
links:
- rabbit
- mqtt
- redis
depends_on:
- rabbit
- mqtt
- redis
web:
container_name: gostemul_docker_web
hostname: gostemul_host_web
restart: always
build:
context: . # Current directory
dockerfile: ./images/web/Dockerfile
command: ./images/web/run_web.sh
volumes:
- .:/code
ports:
- '${WEB_GOST_PORT}:8000'
- '${WEB_DIAGNOSTIC_PORT}:3001'
links:
- rabbit
- mqtt
depends_on:
- rabbit
- mqtt
environment:
- LOCALHOST_MACHINE=${V_LOCALHOST_MACHINE}
- EXPOSED_MQTT_HOST=${V_LOCALHOST_MACHINE}
- EXPOSED_MQTT_PORT=${MQTT_QUEUE_PORT}
- GOST_THINGID_SFN=${GOST_THINGID_SFN_VALUE}
- GOST_THINGID_WRISTBAND=${GOST_THINGID_WRISTBANDS_VALUE}
networks:
- gostemul_docker_network


networks:
gostemul_docker_network:
name: gost_emul_network_${ENVTYPE}
Binary file added images/dbsqlite/db.sqlite3
Binary file not shown.
5 changes: 5 additions & 0 deletions images/mongodb/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# .dockerignore

data/

# Other files and folder
1 change: 1 addition & 0 deletions images/mosquitto/auth/mosquitto_pwd
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mosquitto:$6$sz3bi6DNkGdgCmNz$h8vMcqUXMyuzBhT4jdxEFw8AI4tfMPYAY459SSAhktYPFoVvb9JTZfBaEB3EfgYmNj5fN3qsK4g57rxkPn0rlg==
1 change: 1 addition & 0 deletions images/mosquitto/data/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mosquitto.db
17 changes: 17 additions & 0 deletions images/mosquitto/docker_entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/ash
set -e

if ( [ -z "${MOSQUITTO_USERNAME_VALUE}" ] || [ -z "${MOSQUITTO_PASSWORD_VALUE}" ] ); then
echo "MOSQUITTO_USERNAME_VALUE or MOSQUITTO_PASSWORD_VALUE not defined"
exit 1
fi

echo "START MOSQUITTO PWD GENERATION"

# create mosquitto passwordfile
touch /etc/mosquitto/auth/mosquitto_pwd
mosquitto_passwd -b /etc/mosquitto/auth/mosquitto_pwd ${MOSQUITTO_USERNAME_VALUE} ${MOSQUITTO_PASSWORD_VALUE}

echo "CREATION MOSQUITTO PWD DONE!"

exec mosquitto "$@"
Loading

0 comments on commit dac3eb6

Please sign in to comment.