Commit 994c73f5 authored by Alain Takoudjou's avatar Alain Takoudjou

proxy: create empty slaproxy database if not exits yet

parent 2ba08c68
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
import logging import logging
from slapos.proxy.views import app from slapos.proxy.views import app
from slapos.util import sqlite_connect
def _generateSoftwareProductListFromString(software_product_list_string): def _generateSoftwareProductListFromString(software_product_list_string):
""" """
...@@ -91,10 +92,16 @@ def setupFlaskConfiguration(conf): ...@@ -91,10 +92,16 @@ def setupFlaskConfiguration(conf):
app.config['software_product_list'] = conf.software_product_list app.config['software_product_list'] = conf.software_product_list
app.config['multimaster'] = conf.multimaster app.config['multimaster'] = conf.multimaster
def connectDB():
# if first connection, create an empty db at DATABASE_URI path
conn = sqlite_connect(app.config['DATABASE_URI'])
conn.close()
def do_proxy(conf): def do_proxy(conf):
for handler in conf.logger.handlers: for handler in conf.logger.handlers:
app.logger.addHandler(handler) app.logger.addHandler(handler)
app.logger.setLevel(logging.INFO) app.logger.setLevel(logging.INFO)
setupFlaskConfiguration(conf) setupFlaskConfiguration(conf)
connectDB()
app.run(host=conf.host, port=int(conf.port), threaded=True) app.run(host=conf.host, port=int(conf.port), threaded=True)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment