Skip to content
This repository has been archived by the owner on Mar 26, 2021. It is now read-only.

Commit

Permalink
Добавить 1 переподключение по таймауту refs #5
Browse files Browse the repository at this point in the history
  • Loading branch information
wolf1996 committed May 21, 2018
1 parent 722e1da commit 29155b2
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 11 deletions.
13 changes: 7 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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
2 changes: 1 addition & 1 deletion python/receiver/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0
11
2 changes: 1 addition & 1 deletion python/receiver/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
2 changes: 0 additions & 2 deletions python/receiver/app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

def create_api():
app = Flask(__name__)
logging.basicConfig(level='DEBUG')
print(app.logger_name)
FlaskJSON(app)
register_routes(app)

Expand Down
3 changes: 3 additions & 0 deletions python/receiver/app/data_broker/__init__.py
Original file line number Diff line number Diff line change
@@ -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'],
Expand Down
7 changes: 6 additions & 1 deletion python/receiver/app/data_broker/data_broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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)

0 comments on commit 29155b2

Please sign in to comment.