mirror of
https://github.com/Py-KMS-Organization/py-kms.git
synced 2025-05-13 14:44:50 -04:00
Fixed startup on minimal tag
This commit is contained in:
parent
d3fabf35f1
commit
d795f5265b
1 changed files with 18 additions and 12 deletions
|
@ -20,18 +20,19 @@ argumentVariableMapping = {
|
||||||
'-e': 'EPID'
|
'-e': 'EPID'
|
||||||
}
|
}
|
||||||
|
|
||||||
dbPath = os.path.join(os.sep, 'home', 'py-kms', 'db', 'pykms_database.db')
|
db_path = os.path.join(os.sep, 'home', 'py-kms', 'db', 'pykms_database.db')
|
||||||
log_level_bootstrap = log_level = os.environ.get('LOGLEVEL', 'INFO')
|
log_level_bootstrap = log_level = os.environ.get('LOGLEVEL', 'INFO')
|
||||||
if log_level_bootstrap == "MININFO":
|
if log_level_bootstrap == "MININFO":
|
||||||
log_level_bootstrap = "INFO"
|
log_level_bootstrap = "INFO"
|
||||||
log_file = os.environ.get('LOGFILE', 'STDOUT')
|
log_file = os.environ.get('LOGFILE', 'STDOUT')
|
||||||
listen_ip = os.environ.get('IP', '::').split()
|
listen_ip = os.environ.get('IP', '::').split()
|
||||||
listen_port = os.environ.get('PORT', '1688')
|
listen_port = os.environ.get('PORT', '1688')
|
||||||
|
want_webui = os.environ.get('WEBUI', '0')
|
||||||
|
|
||||||
def start_kms():
|
def start_kms():
|
||||||
# Make sure the full path to the db exists
|
# Make sure the full path to the db exists
|
||||||
if not os.path.exists(os.path.dirname(dbPath)):
|
if want_webui and not os.path.exists(os.path.dirname(db_path)):
|
||||||
os.makedirs(os.path.dirname(dbPath), exist_ok=True)
|
os.makedirs(os.path.dirname(db_path), exist_ok=True)
|
||||||
|
|
||||||
# Build the command to execute
|
# Build the command to execute
|
||||||
command = [PYTHON3, '-u', 'pykms_Server.py', listen_ip[0], listen_port]
|
command = [PYTHON3, '-u', 'pykms_Server.py', listen_ip[0], listen_port]
|
||||||
|
@ -44,16 +45,19 @@ def start_kms():
|
||||||
for i in range(1, len(listen_ip)):
|
for i in range(1, len(listen_ip)):
|
||||||
command.append("-n")
|
command.append("-n")
|
||||||
command.append(listen_ip[i] + "," + listen_port)
|
command.append(listen_ip[i] + "," + listen_port)
|
||||||
|
if want_webui:
|
||||||
command.append('-s')
|
command.append('-s')
|
||||||
command.append(dbPath)
|
command.append(db_path)
|
||||||
|
|
||||||
loggersrv.debug("server_cmd: %s" % (" ".join(str(x) for x in command).strip()))
|
loggersrv.debug("server_cmd: %s" % (" ".join(str(x) for x in command).strip()))
|
||||||
pykms_process = subprocess.Popen(command)
|
pykms_process = subprocess.Popen(command)
|
||||||
|
pykms_webui_process = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
if want_webui:
|
||||||
time.sleep(2) # Wait for the server to start up
|
time.sleep(2) # Wait for the server to start up
|
||||||
pykms_webui_env = os.environ.copy()
|
pykms_webui_env = os.environ.copy()
|
||||||
pykms_webui_env['PYKMS_SQLITE_DB_PATH'] = dbPath
|
pykms_webui_env['PYKMS_SQLITE_DB_PATH'] = db_path
|
||||||
pykms_webui_env['PORT'] = '8080'
|
pykms_webui_env['PORT'] = '8080'
|
||||||
pykms_webui_env['PYKMS_LICENSE_PATH'] = '/LICENSE'
|
pykms_webui_env['PYKMS_LICENSE_PATH'] = '/LICENSE'
|
||||||
pykms_webui_process = subprocess.Popen(['gunicorn', '--log-level', os.environ.get('LOGLEVEL'), 'pykms_WebUI:app'], env=pykms_webui_env)
|
pykms_webui_process = subprocess.Popen(['gunicorn', '--log-level', os.environ.get('LOGLEVEL'), 'pykms_WebUI:app'], env=pykms_webui_env)
|
||||||
|
@ -67,6 +71,8 @@ def start_kms():
|
||||||
pass
|
pass
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
if pykms_webui_process:
|
||||||
pykms_webui_process.terminate()
|
pykms_webui_process.terminate()
|
||||||
pykms_process.terminate()
|
pykms_process.terminate()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue