|
@@ -49,6 +49,7 @@ if TYPE_CHECKING:
|
|
from pynecone.components.component import ImportDict
|
|
from pynecone.components.component import ImportDict
|
|
from pynecone.config import Config
|
|
from pynecone.config import Config
|
|
from pynecone.event import Event, EventHandler, EventSpec
|
|
from pynecone.event import Event, EventHandler, EventSpec
|
|
|
|
+ from pynecone.model import Model
|
|
from pynecone.var import Var
|
|
from pynecone.var import Var
|
|
|
|
|
|
# Shorthand for join.
|
|
# Shorthand for join.
|
|
@@ -714,6 +715,15 @@ def change_or_terminate_port(port, _type) -> str:
|
|
sys.exit()
|
|
sys.exit()
|
|
|
|
|
|
|
|
|
|
|
|
+def setup_backend():
|
|
|
|
+ """Sets up backend. Specifically ensures backend
|
|
|
|
+ database is updated when running --no-frontend.
|
|
|
|
+ """
|
|
|
|
+ config = get_config()
|
|
|
|
+ if config.db_url is not None:
|
|
|
|
+ Model.create_all()
|
|
|
|
+
|
|
|
|
+
|
|
def run_backend(
|
|
def run_backend(
|
|
app_name: str, port: int, loglevel: constants.LogLevel = constants.LogLevel.ERROR
|
|
app_name: str, port: int, loglevel: constants.LogLevel = constants.LogLevel.ERROR
|
|
):
|
|
):
|
|
@@ -724,6 +734,8 @@ def run_backend(
|
|
port: The app port
|
|
port: The app port
|
|
loglevel: The log level.
|
|
loglevel: The log level.
|
|
"""
|
|
"""
|
|
|
|
+ setup_backend()
|
|
|
|
+
|
|
uvicorn.run(
|
|
uvicorn.run(
|
|
f"{app_name}:{constants.APP_VAR}.{constants.API_VAR}",
|
|
f"{app_name}:{constants.APP_VAR}.{constants.API_VAR}",
|
|
host=constants.BACKEND_HOST,
|
|
host=constants.BACKEND_HOST,
|
|
@@ -743,6 +755,8 @@ def run_backend_prod(
|
|
port: The app port
|
|
port: The app port
|
|
loglevel: The log level.
|
|
loglevel: The log level.
|
|
"""
|
|
"""
|
|
|
|
+ setup_backend()
|
|
|
|
+
|
|
num_workers = get_num_workers()
|
|
num_workers = get_num_workers()
|
|
command = constants.RUN_BACKEND_PROD + [
|
|
command = constants.RUN_BACKEND_PROD + [
|
|
"--bind",
|
|
"--bind",
|