forked from langgenius/dify
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'langgenius:main' into main
- Loading branch information
Showing
1,253 changed files
with
29,350 additions
and
11,438 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,41 @@ | ||
from app_factory import create_app | ||
from libs import threadings_utils, version_utils | ||
import os | ||
import sys | ||
|
||
|
||
def is_db_command(): | ||
if len(sys.argv) > 1 and sys.argv[0].endswith("flask") and sys.argv[1] == "db": | ||
return True | ||
return False | ||
|
||
# preparation before creating app | ||
version_utils.check_supported_python_version() | ||
threadings_utils.apply_gevent_threading_patch() | ||
|
||
# create app | ||
app = create_app() | ||
celery = app.extensions["celery"] | ||
if is_db_command(): | ||
from app_factory import create_migrations_app | ||
|
||
app = create_migrations_app() | ||
else: | ||
# It seems that JetBrains Python debugger does not work well with gevent, | ||
# so we need to disable gevent in debug mode. | ||
# If you are using debugpy and set GEVENT_SUPPORT=True, you can debug with gevent. | ||
if (flask_debug := os.environ.get("FLASK_DEBUG", "0")) and flask_debug.lower() in {"false", "0", "no"}: | ||
from gevent import monkey # type: ignore | ||
|
||
# gevent | ||
monkey.patch_all() | ||
|
||
from grpc.experimental import gevent as grpc_gevent # type: ignore | ||
|
||
# grpc gevent | ||
grpc_gevent.init_gevent() | ||
|
||
import psycogreen.gevent # type: ignore | ||
|
||
psycogreen.gevent.patch_psycopg() | ||
|
||
from app_factory import create_app | ||
|
||
app = create_app() | ||
celery = app.extensions["celery"] | ||
|
||
if __name__ == "__main__": | ||
app.run(host="0.0.0.0", port=5001) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.