Change default location for db and logs to ~/.caravel Fix #915 (#947)

This commit is contained in:
Adam Jones 2016-08-17 00:35:31 -04:00 committed by Maxime Beauchemin
parent 66c2b84cb4
commit 88f4260777
3 changed files with 9 additions and 11 deletions

View File

@ -15,7 +15,9 @@ from dateutil import tz
from flask_appbuilder.security.manager import AUTH_DB
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
DATA_DIR = os.path.join(os.path.expanduser('~'), '.caravel')
if not os.path.exists(DATA_DIR):
os.makedirs(DATA_DIR)
# ---------------------------------------------------------
# Caravel specific config
@ -34,10 +36,7 @@ CUSTOM_SECURITY_MANAGER = None
SECRET_KEY = '\2\1thisismyscretkey\1\2\e\y\y\h' # noqa
# The SQLAlchemy connection string.
SQLALCHEMY_DATABASE_URI = 'sqlite:////tmp/caravel.db'
# this is for platform specific: "nt" is for windows, "posix" is *nix (including Mac)
if os.name == "nt":
SQLALCHEMY_DATABASE_URI = 'sqlite:///c:\\tmp\\caravel.db'
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(DATA_DIR, 'caravel.db')
# SQLALCHEMY_DATABASE_URI = 'mysql://myapp@localhost/myapp'
# SQLALCHEMY_DATABASE_URI = 'postgresql://root:password@localhost/myapp'
@ -172,7 +171,7 @@ LOG_LEVEL = 'DEBUG'
ENABLE_TIME_ROTATE = False
TIME_ROTATE_LOG_LEVEL = 'DEBUG'
FILENAME = '/tmp/caravel.log'
FILENAME = os.path.join(DATA_DIR, 'caravel.log')
ROLLOVER = 'midnight'
INTERVAL = 1
BACKUP_COUNT = 30

View File

@ -136,7 +136,7 @@ of the parameters you can copy / paste in that configuration module: ::
# caravel metadata (slices, connections, tables, dashboards, ...).
# Note that the connection information to connect to the datasources
# you want to explore are managed directly in the web UI
SQLALCHEMY_DATABASE_URI = 'sqlite:////tmp/caravel.db'
SQLALCHEMY_DATABASE_URI = 'sqlite:////path/to/caravel.db'
# Flask-WTF flag for CSRF
CSRF_ENABLED = True
@ -149,7 +149,7 @@ for more information on how to configure Caravel.
Please make sure to change:
* *SQLALCHEMY_DATABASE_URI*, by default it is stored on */tmp* and so will be cleared after each boot
* *SQLALCHEMY_DATABASE_URI*, by default it is stored at *~/.caravel/caravel.db*
* *SECRET_KEY*, to a long random string
Database dependencies
@ -202,7 +202,7 @@ complies with the Flask-Cache specifications.
Flask-Cache supports multiple caching backends (Redis, Memcached,
SimpleCache (in-memory), or the local filesystem). If you are going to use
Memcached please use the pylibmc client library as python-memcached does
not handle storing binary data correctly. If you use Redis, please install
not handle storing binary data correctly. If you use Redis, please install
[python-redis](https://pypi.python.org/pypi/redis).
For setting your timeouts, this is done in the Caravel metadata and goes

View File

@ -1,7 +1,7 @@
from caravel.config import *
AUTH_USER_REGISTRATION_ROLE = 'alpha'
SQLALCHEMY_DATABASE_URI = 'sqlite:////tmp/caravel_unittests.db'
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + os.path.join(DATA_DIR, 'unittests.db')
DEBUG = True
CARAVEL_WEBSERVER_PORT = 8081
@ -9,4 +9,3 @@ CARAVEL_WEBSERVER_PORT = 8081
# continuous integration
if 'CARAVEL__SQLALCHEMY_DATABASE_URI' in os.environ:
SQLALCHEMY_DATABASE_URI = os.environ.get('CARAVEL__SQLALCHEMY_DATABASE_URI')