From 7e83b2d612119112b9e773c2dc074ad1ef51dfb2 Mon Sep 17 00:00:00 2001 From: Drasko DRASKOVIC Date: Thu, 16 Aug 2018 19:52:43 +0200 Subject: [PATCH] NOISSUE - Add system run script (#350) * NOISSUE - Add system run script Signed-off-by: drasko * Add MQTT Signed-off-by: drasko * Add MQTT module install to Makefile. Fix warnings. Signed-off-by: drasko --- Makefile | 11 ++++++-- mqtt/package.json | 9 ++++--- package-lock.json | 3 +++ scripts/run.sh | 65 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 82 insertions(+), 6 deletions(-) create mode 100644 package-lock.json create mode 100755 scripts/run.sh diff --git a/Makefile b/Makefile index d307a5a4..627ff73d 100644 --- a/Makefile +++ b/Makefile @@ -12,12 +12,13 @@ define make_docker docker build --build-arg SVC_NAME=$(subst docker_,,$(1)) --tag=mainflux/$(subst docker_,,$(1)) -f docker/Dockerfile . endef -all: $(SERVICES) +all: $(SERVICES) mqtt -.PHONY: all $(SERVICES) dockers latest release +.PHONY: all $(SERVICES) dockers latest release mqtt clean: rm -rf ${BUILD_DIR} + rm -rf mqtt/node_modules install: cp ${BUILD_DIR}/* $(GOBIN) @@ -35,6 +36,9 @@ dockers: $(DOCKERS) docker build --tag=mainflux/dashflux -f dashflux/docker/Dockerfile dashflux docker build --tag=mainflux/mqtt -f mqtt/Dockerfile . +mqtt: + cd mqtt && npm install + latest: dockers for svc in $(SERVICES); do \ docker push mainflux/$$svc; \ @@ -54,3 +58,6 @@ release: docker push mainflux/dashflux:$(version) docker tag mainflux/mqtt mainflux/mqtt:$(version) docker push mainflux/mqtt:$(version) + +run: + cd scripts && ./run.sh diff --git a/mqtt/package.json b/mqtt/package.json index 65bf1767..b5236de4 100644 --- a/mqtt/package.json +++ b/mqtt/package.json @@ -13,13 +13,14 @@ "lint": "eslint mqtt.js" }, "dependencies": { - "aedes": "^0.34.0", + "2": "^1.0.2", + "aedes": "^0.35.2", "aedes-logging": "^1.0.1", "aedes-persistence-redis": "^5.1.0", "atob": "^2.0.3", "bunyan": "^1.5.1", "grpc": "^1.11.3", - "lodash": "~3.10.1", + "lodash": "^4.17.10", "nats": "^0.6.8", "protocol-buffers": "^4.0.4", "request": "^2.81.0", @@ -32,7 +33,7 @@ "eslint-config-airbnb-base": "^12.0.1", "eslint-plugin-import": "^2.7.0", "jshint-stylish": "^2.0.1", - "mocha": "^2.3.3", - "supertest": "^1.1.0" + "mocha": "^5.2.0", + "supertest": "^3.1.0" } } diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 00000000..48e341a0 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,3 @@ +{ + "lockfileVersion": 1 +} diff --git a/scripts/run.sh b/scripts/run.sh new file mode 100755 index 00000000..7752bec7 --- /dev/null +++ b/scripts/run.sh @@ -0,0 +1,65 @@ +#!/bin/bash +# +# Copyright (c) 2018 +# Mainflux +# +# SPDX-License-Identifier: Apache-2.0 +# + +### +# Runs all Mainflux microservices (must be previously built and installed). +# +# Expects that PostgreSQL and needed messaging DB are alredy running. +# Additionally, MQTT microservice demands that Redis is up and running. +# +### + +BUILD_DIR=../build + +# Kill all mainflux-* stuff +function cleanup { + pkill mainflux + pkill nats +} + +### +# NATS +### +gnatsd & + +### +# Users +### +$BUILD_DIR/mainflux-users & + +### +# Things +### +MF_THINGS_HTTP_PORT=8182 MF_THINGS_GRPC_PORT=8183 $BUILD_DIR/mainflux-things & + +### +# HTTP +### +MF_HTTP_ADAPTER_PORT=8185 MF_THINGS_URL=localhost:8183 $BUILD_DIR/mainflux-http & + +### +# WS +### +MF_WS_ADAPTER_PORT=8186 MF_THINGS_URL=localhost:8183 $BUILD_DIR/mainflux-ws & + +### +# MQTT +### +# Switch to top dir to find *.proto stuff when running MQTT broker +cd .. +MF_THINGS_URL=localhost:8183 node mqtt/mqtt.js & +cd - + +### +# CoAP +### +# TODO: add coap + +trap cleanup EXIT + +while : ; do sleep 1 ; done