Skip to content

Commit

Permalink
print out fact version + git hash on start
Browse files Browse the repository at this point in the history
  • Loading branch information
jstucke committed Dec 15, 2023
1 parent 3ae3656 commit fd21fb2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/fact_base.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
import logging
import os
import signal
import sys
from pathlib import Path
from time import sleep

import config

try:
import git
import psutil
import psycopg2 # noqa: F401

from helperFunctions.program_setup import setup_argparser, setup_logging
from statistic.work_load import WorkLoadStatistic
from storage.db_interface_base import DbInterfaceError
from storage.migration import db_needs_migration
from version import __VERSION__
except (ImportError, ModuleNotFoundError):
logging.exception(
'Could not load dependencies. Please make sure that you have installed FACT correctly '
Expand All @@ -37,11 +41,23 @@ def __init__(self):
self.args = setup_argparser(self.PROGRAM_NAME, self.PROGRAM_DESCRIPTION)
config.load(self.args.config_file)
setup_logging(self.args, self.COMPONENT)
python_version, *_ = sys.version.split(' ')
logging.info(
f'Starting {self.PROGRAM_NAME} @ {__VERSION__} ({self._get_git_revision()}, Python {python_version})'
)
self.do_self_test()

self._register_signal_handlers()
self.work_load_stat = WorkLoadStatistic(component=self.COMPONENT)

@staticmethod
def _get_git_revision() -> str:
try:
repo = git.Repo(Path(__file__), search_parent_directories=True)
return f'commit {repo.head.object.hexsha}'
except git.exc.InvalidGitRepositoryError:
return 'unknown revision'

def _register_signal_handlers(self):
# Check whether the process was started by start_fact.py
parent = ' '.join(psutil.Process(os.getppid()).cmdline())
Expand Down
1 change: 1 addition & 0 deletions src/install/requirements_common.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ setuptools<66
# General python dependencies
appdirs==1.4.4
flaky==3.7.0
gitpython~=3.1.40
lief==0.12.3
psutil==5.9.4
psycopg2-binary==2.9.5
Expand Down

0 comments on commit fd21fb2

Please sign in to comment.