def __init__(self, config_dir):
        self.app = Flask(__name__)
        self.service_map = {}
        self.event_map = {}
        signal.signal(signal.SIGTERM, self.term_handler)
        signal.signal(signal.SIGQUIT, self.term_handler)
        signal.signal(signal.SIGINT, self.term_handler)

        with open(config_dir) as config_fd:
            self.api_config = yaml.load(config_fd)
        self.api_fifo_name = str(uuid.uuid4()) + '.fifo'
        self.api_fifo_path = os.path.join(ApiConstants.API_PIPE_DIR,
                                          self.api_fifo_name)
        os.mkfifo(self.api_fifo_path)
        try:
            self.api_fifo_fd = os.open(self.api_fifo_path, os.O_NONBLOCK)
            self.api_fifo_file = os.fdopen(self.api_fifo_fd)
        except (IOError, OSError) as exc:
            print ("Unable to read the fifo file due to error {0} "
                   .format(exc))
            raise

        if not os.path.exists(self.api_config['moirai_input_fifo']):
            os.mkfifo(self.api_config['moirai_input_fifo'])

        try:
            self.moirai_fifo_fd = os.open(self.api_config['moirai_input_fifo'],
                                          os.O_WRONLY | os.O_NONBLOCK)
            self.moirai_fifo_file = os.fdopen(self.moirai_fifo_fd, 'w')
        except (__HOLE__, OSError) as exc:
            print "Unable to connect to Moirai Server"
            self.moirai_fifo_fd = None
        self.setup_routes()
        self.command_id = 0
dataset/ETHPy150Open linkedin/simoorg/src/simoorg/Api/MoiraiApiServer.py/MoiraiApiServer.__init__