1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-12-25 09:30:31 +00:00

Read dbpath from $CALIBRE_DBPATH if present

This is an exploration in potentially enabling multiple libraries to run using the same engine. 

Since app config is all in the db, we should get no port conflicts and be able to run multiple instances of this app with no issues.

Using os.getenv instead of os.environ.get allows us to provide CALIBRE_DBPATH inline with the invocation of the file (`CALIBRE_DBPATH=/foo/bar/` python cps.py)
This commit is contained in:
Ivan Smirnov 2017-03-25 13:05:44 -07:00 committed by GitHub
parent cbc807f3ff
commit 2c173f9848

View File

@ -13,7 +13,7 @@ from flask_babel import gettext as _
import json
#from builtins import str
dbpath = os.path.join(os.path.normpath(os.path.dirname(os.path.realpath(__file__)) + os.sep + ".." + os.sep), "app.db")
dbpath = os.path.join(os.path.normpath(os.getenv("CALIBRE_DBPATH", os.path.dirname(os.path.realpath(__file__)) + os.sep + ".." + os.sep)), "app.db")
engine = create_engine('sqlite:///{0}'.format(dbpath), echo=False)
Base = declarative_base()