improve connection handling on startup
This commit is contained in:
parent
6597c46a9d
commit
e5e262fd4f
@ -13,8 +13,6 @@ from .api import ships
|
|||||||
from .api import login
|
from .api import login
|
||||||
from .api import user
|
from .api import user
|
||||||
|
|
||||||
sessions = dict()
|
|
||||||
|
|
||||||
def create_app(test_config=None):
|
def create_app(test_config=None):
|
||||||
|
|
||||||
app = Flask(__name__, instance_relative_config=True)
|
app = Flask(__name__, instance_relative_config=True)
|
||||||
@ -44,7 +42,7 @@ def create_app(test_config=None):
|
|||||||
|
|
||||||
|
|
||||||
logging.basicConfig(filename='brecal.log', level=logging.DEBUG, format='%(asctime)s | %(name)s | %(levelname)s | %(message)s')
|
logging.basicConfig(filename='brecal.log', level=logging.DEBUG, format='%(asctime)s | %(name)s | %(levelname)s | %(message)s')
|
||||||
local_db.initPool()
|
local_db.initPool(app.instance_path)
|
||||||
logging.info('App started')
|
logging.info('App started')
|
||||||
|
|
||||||
return app
|
return app
|
||||||
|
|||||||
@ -4,13 +4,14 @@ import logging
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
|
||||||
connection_pool = None
|
config_path = None
|
||||||
|
|
||||||
def initPool():
|
def initPool(instancePath):
|
||||||
try:
|
try:
|
||||||
|
if(config_path == None):
|
||||||
|
config_path = os.path.join(instancePath,'../../../../secure/connection_data_test.json');
|
||||||
|
|
||||||
config_path = '../../../../secure/connection_data_test.json'
|
print (instancePath)
|
||||||
print (os.getcwd())
|
|
||||||
if not os.path.exists(config_path):
|
if not os.path.exists(config_path):
|
||||||
print ('cannot find ' + config_path)
|
print ('cannot find ' + config_path)
|
||||||
exit(1)
|
exit(1)
|
||||||
@ -31,7 +32,6 @@ def initPool():
|
|||||||
print(e)
|
print(e)
|
||||||
|
|
||||||
def getPoolConnection():
|
def getPoolConnection():
|
||||||
config_path = '../../../../secure/connection_data_test.json'
|
|
||||||
f = open(config_path);
|
f = open(config_path);
|
||||||
connection_data = json.load(f)
|
connection_data = json.load(f)
|
||||||
return mysql.connector.connect(**connection_data)
|
return mysql.connector.connect(**connection_data)
|
||||||
@ -1,8 +1,8 @@
|
|||||||
import sys
|
import sys
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
sys.path.insert(0, '/var/www/brecal/server')
|
sys.path.insert(0, '/var/www/brecal_test/server')
|
||||||
sys.path.insert(0, '/var/www/brecal/venv/lib/python3.10/site-packages/')
|
sys.path.insert(0, '/var/www/venv/lib/python3.10/site-packages/')
|
||||||
|
|
||||||
# Set up logging
|
# Set up logging
|
||||||
logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
|
logging.basicConfig(stream=sys.stderr, level=logging.DEBUG)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user