summaryrefslogtreecommitdiff
path: root/heap/datastore/server.py
diff options
context:
space:
mode:
authorEbus-at-dockstar <ebus@dockstar>2013-03-25 10:24:28 +0100
committerEbus-at-dockstar <ebus@dockstar>2013-03-25 10:24:43 +0100
commit862282ce99760832d3e9e5b4b1171b861105e004 (patch)
tree0e229418e391917b79d42a8bdee46fb7a8612895 /heap/datastore/server.py
parent9522cdffa94f278eb5e1894600535986e22c2890 (diff)
downloadebus-alt-862282ce99760832d3e9e5b4b1171b861105e004.tar.gz
ebus-alt-862282ce99760832d3e9e5b4b1171b861105e004.zip
move old stuff away
Diffstat (limited to 'heap/datastore/server.py')
-rw-r--r--heap/datastore/server.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/heap/datastore/server.py b/heap/datastore/server.py
new file mode 100644
index 0000000..8b9ca4e
--- /dev/null
+++ b/heap/datastore/server.py
@@ -0,0 +1,36 @@
+from sys import exit
+from stompclient import PublishSubscribeClient
+from threading import Thread
+from store.controller import MQStoreController
+from time import sleep
+
+import config
+
+client = PublishSubscribeClient(config.STOMP_HOST, config.STOMP_PORT)
+listener = Thread(target=client.listen_forever, name='Frame-Receiver')
+listener.start()
+client.listening_event.wait()
+r = client.connect(config.STOMP_LOGIN, config.STOMP_PASSCODE)
+if r.command != "CONNECTED":
+ print "Failed to connect to {0}:{1}".format(config.STOMP_HOST,config.STOMP_PORT)
+ print r
+ exit(1)
+
+
+controller = MQStoreController(client, config.CHANNELS, config.PROCESSORS)
+client.subscribe(config.STOMP_QUEUE_PUT, controller.cb_put)
+client.subscribe(config.STOMP_QUEUE_GET, controller.cb_get)
+client.subscribe(config.STOMP_QUEUE_SUBSCRIBE, controller.cb_subscribe)
+
+while True:
+ try:
+ sleep(1)
+ except KeyboardInterrupt:
+ print "shutdown"
+ try:
+ client.shutdown_event.set()
+ except:
+ pass
+ exit(0)
+
+