add sqldb init
This commit is contained in:
@@ -3,6 +3,19 @@ nodaemon=true
|
|||||||
logfile=/dev/null
|
logfile=/dev/null
|
||||||
pidfile=/var/run/supervisord.pid
|
pidfile=/var/run/supervisord.pid
|
||||||
|
|
||||||
|
; --- Database Init ---
|
||||||
|
[program:initdb]
|
||||||
|
directory=/app/server
|
||||||
|
command=/usr/local/bin/python database.py
|
||||||
|
autostart=true
|
||||||
|
autorestart=false
|
||||||
|
startsecs=0
|
||||||
|
stdout_logfile=/dev/stdout
|
||||||
|
stderr_logfile=/dev/stderr
|
||||||
|
stdout_logfile_maxbytes=0
|
||||||
|
stderr_logfile_maxbytes=0
|
||||||
|
priority=5
|
||||||
|
|
||||||
; --- Flask API (gunicorn) ---
|
; --- Flask API (gunicorn) ---
|
||||||
[program:api]
|
[program:api]
|
||||||
directory=/app/server
|
directory=/app/server
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ except ImportError:
|
|||||||
DB_TYPE = 'sqlite3'
|
DB_TYPE = 'sqlite3'
|
||||||
|
|
||||||
BASE_DIR = Path(__file__).resolve().parent
|
BASE_DIR = Path(__file__).resolve().parent
|
||||||
SCHEMA_PATH = BASE_DIR / "schema.sql" if DB_TYPE != 'sqlite3' else BASE_DIR / "schema_sqlite.sql"
|
|
||||||
DATABASE_URL = os.getenv("DATABASE_URL")
|
DATABASE_URL = os.getenv("DATABASE_URL")
|
||||||
SQLITE_PATH = BASE_DIR / "instance" / "dev.db"
|
SQLITE_PATH = BASE_DIR / "instance" / "dev.db"
|
||||||
|
|
||||||
@@ -18,6 +18,10 @@ SQLITE_PATH = BASE_DIR / "instance" / "dev.db"
|
|||||||
def is_postgres():
|
def is_postgres():
|
||||||
return DATABASE_URL and DATABASE_URL.lower().startswith("postgres")
|
return DATABASE_URL and DATABASE_URL.lower().startswith("postgres")
|
||||||
|
|
||||||
|
if is_postgres():
|
||||||
|
SCHEMA_PATH = BASE_DIR / "schema.sql"
|
||||||
|
else:
|
||||||
|
SCHEMA_PATH = BASE_DIR / "schema_sqlite.sql"
|
||||||
|
|
||||||
def get_connection():
|
def get_connection():
|
||||||
if is_postgres():
|
if is_postgres():
|
||||||
|
|||||||
Reference in New Issue
Block a user