1
1
import logging
2
2
import os
3
3
import signal
4
+ import sys
5
+ from pathlib import Path
4
6
from time import sleep
5
7
6
8
import config
7
9
8
10
try :
11
+ import git
9
12
import psutil
10
13
import psycopg2 # noqa: F401
11
14
12
15
from helperFunctions .program_setup import setup_argparser , setup_logging
13
16
from statistic .work_load import WorkLoadStatistic
14
17
from storage .db_interface_base import DbInterfaceError
15
18
from storage .migration import db_needs_migration
19
+ from version import __VERSION__
16
20
except (ImportError , ModuleNotFoundError ):
17
21
logging .exception (
18
22
'Could not load dependencies. Please make sure that you have installed FACT correctly '
@@ -37,11 +41,23 @@ def __init__(self):
37
41
self .args = setup_argparser (self .PROGRAM_NAME , self .PROGRAM_DESCRIPTION )
38
42
config .load (self .args .config_file )
39
43
setup_logging (self .args , self .COMPONENT )
44
+ python_version , * _ = sys .version .split (' ' )
45
+ logging .info (
46
+ f'Starting { self .PROGRAM_NAME } @ { __VERSION__ } ({ self ._get_git_revision ()} , Python { python_version } )'
47
+ )
40
48
self .do_self_test ()
41
49
42
50
self ._register_signal_handlers ()
43
51
self .work_load_stat = WorkLoadStatistic (component = self .COMPONENT )
44
52
53
+ @staticmethod
54
+ def _get_git_revision () -> str :
55
+ try :
56
+ repo = git .Repo (Path (__file__ ), search_parent_directories = True )
57
+ return f'commit { repo .head .object .hexsha } '
58
+ except git .exc .InvalidGitRepositoryError :
59
+ return 'unknown revision'
60
+
45
61
def _register_signal_handlers (self ):
46
62
# Check whether the process was started by start_fact.py
47
63
parent = ' ' .join (psutil .Process (os .getppid ()).cmdline ())
0 commit comments