diff --git a/Makefile b/Makefile index 74ea122..887d156 100644 --- a/Makefile +++ b/Makefile @@ -121,7 +121,6 @@ kubernetes_data_deployment_remove: kubernetes_data_service_remove: $(MAKE) -C python/data kubernetes_service_remove - #Собираем новый образ и запускаем kubernetes_data_buildnload: $(MAKE) -C python/data kubernetes_buildnload @@ -160,17 +159,17 @@ kubernetes_gateway_buildnload: $(MAKE) -C python/gateway kubernetes_buildnload -# reciever kubernetes -kubernetes_reciever_service: +# receiver kubernetes +kubernetes_receiver_service: $(MAKE) -C python/receiver kubernetes_service -kubernetes_reciever_deployment: +kubernetes_receiver_deployment: $(MAKE) -C python/receiver kubernetes_deployment -kubernetes_reciever_deployment_remove: +kubernetes_receiver_deployment_remove: $(MAKE) -C python/receiver kubernetes_deployment_remove -kubernetes_reciever_service_remove: +kubernetes_receiver_service_remove: $(MAKE) -C python/receiver kubernetes_service_remove kubernetes_receiver_buildnload: @@ -185,6 +184,8 @@ kubernetes_install_dns: helm_install_mongo: helm install --name mongodb --set replicas=1 stable/mongodb-replicaset +# echo URL : http://127.0.0.1:15672 +# kubectl port-forward rabbitmq-0 --namespace default 5672:5672 15672:15672 # устанавливаем rabbitmq helm_install_rabbitmq: helm install --name rabbitmq --set rabbitmq.username=user,rabbitmq.password=user,persistence.enabled=false,rbacEnabled=true stable/rabbitmq \ No newline at end of file diff --git a/python/receiver/VERSION b/python/receiver/VERSION index c227083..b4de394 100644 --- a/python/receiver/VERSION +++ b/python/receiver/VERSION @@ -1 +1 @@ -0 \ No newline at end of file +11 diff --git a/python/receiver/app.py b/python/receiver/app.py index c3b03a7..3f44b36 100755 --- a/python/receiver/app.py +++ b/python/receiver/app.py @@ -2,10 +2,10 @@ from app import create_api from configuration import config_flask +import logging if __name__ == '__main__': app = create_api() - app.run( debug=bool(config_flask['debug']), host=config_flask['host'], diff --git a/python/receiver/app/__init__.py b/python/receiver/app/__init__.py index 53d5ba0..afd16f4 100644 --- a/python/receiver/app/__init__.py +++ b/python/receiver/app/__init__.py @@ -6,8 +6,6 @@ def create_api(): app = Flask(__name__) - logging.basicConfig(level='DEBUG') - print(app.logger_name) FlaskJSON(app) register_routes(app) diff --git a/python/receiver/app/data_broker/__init__.py b/python/receiver/app/data_broker/__init__.py index ae3f654..e253d10 100644 --- a/python/receiver/app/data_broker/__init__.py +++ b/python/receiver/app/data_broker/__init__.py @@ -1,5 +1,8 @@ from .data_broker import DataBroker from configuration import config_rabbit +import logging + +logging.basicConfig(level='DEBUG') data_broker = DataBroker( host=config_rabbit['host'], diff --git a/python/receiver/app/data_broker/data_broker.py b/python/receiver/app/data_broker/data_broker.py index d19d4f3..bdff39f 100644 --- a/python/receiver/app/data_broker/data_broker.py +++ b/python/receiver/app/data_broker/data_broker.py @@ -10,7 +10,11 @@ class DataBroker: def __init__(self, host, port=5672): credentials = pika.PlainCredentials('user','user') - self._connection = pika.BlockingConnection(pika.ConnectionParameters(host=host, port=port,credentials=credentials, heartbeat=0)) + self._params = pika.ConnectionParameters(host=host, port=port,credentials=credentials) + self.connect() + + def connect(self): + self._connection = pika.BlockingConnection(self._params) self._chanel = self._connection.channel() self._declare_sensor_data_queue() @@ -31,4 +35,5 @@ def send_sensor_data(self, sensor_data): self._send_data(sensor_data) except pika.exceptions.ConnectionClosed as e: log.error("failed to connect {}".format(str(e))) + self.connect() self._send_data(sensor_data) \ No newline at end of file