from hub import methods, Global

import threading
import time
import json
import os

# --- for linux
# save_dir = f"/home/server/logs"

# --- for windows
# save_dir = r'C:\SRI-DINO.Server-py\logs'  # sri内网测试环境
save_dir = r'C:\logs'  # sri内网测试环境


class MessageListener(object):
    """
    """

    @classmethod
    def run(cls, background_is=True):

        from lib.UserWorkRecord import UserWorkRecord
        UserWorkRecord.init()

        from lib.MessageListenerC001 import subscribe_c001
        from lib.MessageListenerV001 import subscribe_v001

        thread_list = [
            threading.Thread(target=subscribe_c001),
            threading.Thread(target=subscribe_v001),
        ]
        for thread in thread_list:
            thread.setDaemon(True)
            thread.start()
        if background_is:
            return
        for thread in thread_list:
            thread.join()


if __name__ == '__main__':
    # --- test ---
    MessageListener.run()