diff options
author | Yves Fischer <yvesf-git@xapek.org> | 2013-01-11 20:01:09 +0100 |
---|---|---|
committer | Yves Fischer <yvesf-git@xapek.org> | 2013-01-11 20:01:09 +0100 |
commit | 934d642b410d75dae1966c993fc61c371959876e (patch) | |
tree | ca9bcd22d98d88424be0d21d6387ddba779a9daa /datastore/server.py | |
parent | 69fbdff8e8ba69034111038ce01184ef5472728a (diff) | |
download | ebus-alt-934d642b410d75dae1966c993fc61c371959876e.tar.gz ebus-alt-934d642b410d75dae1966c993fc61c371959876e.zip |
datastore
Diffstat (limited to 'datastore/server.py')
-rw-r--r-- | datastore/server.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/datastore/server.py b/datastore/server.py new file mode 100644 index 0000000..8b9ca4e --- /dev/null +++ b/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) + + |