aura.py 1.17 KB
Newer Older
1
2
3
4
5
6
import signal
import sys
import threading

from libraries.base.config import ConfigReader
from libraries.reporting.messenger import AuraMessenger
7
from modules.controller.controller import AuraController
8
9
10
from modules.communication.zmq.zmqadapter import ServerZMQAdapter


11
12
class Aura():
    server = None
13
14
    config = None
    messenger = None
15
    controller = None
16
17
18
19
20
21

    def __init__(self):
        self.config = ConfigReader()
        self.config.loadConfig()

        messenger = AuraMessenger()
22
        messenger.set_channel("aura")
23
24
25

        server = object

26
27
        self.controller = AuraController(self.config, debug=True)
        self.server = ServerZMQAdapter(self.controller, self.config, debug=True)
28

29
30
31
32
33
34
        def receive_signal(signum, stack):
            print("received signal")
            server.reload()

        signal.signal(signal.SIGUSR1, receive_signal)

35
    def join_comm(self):
36
        # start listener thread
37
        self.server.join_comm()
38
39
40
41
42
43

# # ## ## ## ## ## # #
# # ENTRY FUNCTION # #
# # ## ## ## ## ## # #
def main():
    aura = Aura()
44
    aura.join_comm()
45
46
47
48
49
50
51

# # ## ## ## ## ## ## # #
# # End ENTRY FUNCTION # #
# # ## ## ## ## ## ## # #

if __name__ == "__main__":
    main()