fix: [core] fix instance ail:uuid

pull/594/head
Terrtia 2023-05-15 10:37:03 +02:00
parent 8ec4370043
commit 2ae3ffd6d2
No known key found for this signature in database
GPG Key ID: 1E1B1F50D84613D0
3 changed files with 19 additions and 3 deletions

View File

@ -10,13 +10,23 @@ Init DB + Clear Stats
import os
import sys
import logging.config
sys.path.append(os.environ['AIL_BIN'])
##################################
# Import Project packages
##################################
from lib import ail_core
from lib import ail_queues
from lib import ail_logger
logging.config.dictConfig(ail_logger.get_config(name='modules'))
logger = logging.getLogger()
if __name__ == "__main__":
ail_queues.save_queue_digraph()
ail_queues.clear_modules_queues_stats()
# Send module state to logs
ail_uuid = ail_core.get_ail_uuid()
logger.warning(f"AIL {ail_uuid} started")

View File

@ -18,7 +18,15 @@ config_loader = None
AIL_OBJECTS = sorted({'cve', 'cryptocurrency', 'decoded', 'domain', 'item', 'pgp', 'screenshot', 'username'})
def get_ail_uuid():
return r_serv_db.get('ail:uuid')
ail_uuid = r_serv_db.get('ail:uuid')
if not ail_uuid:
ail_uuid = _set_ail_uuid()
return ail_uuid
def _set_ail_uuid():
ail_uuid = generate_uuid()
r_serv_db.set('ail:uuid', ail_uuid)
return ail_uuid
def generate_uuid():
return str(uuid4())

View File

@ -68,8 +68,6 @@ class Global(AbstractModule):
# Send module state to logs
self.logger.info(f"Module {self.module_name} initialized")
# Send module state to logs # TODO MOVE ME IN INIT SCRIPT
self.redis_logger.critical(f"AIL {get_ail_uuid()} started")
def computeNone(self):
difftime = time.time() - self.time_last_stats