Skip to content

Commit

Permalink
ext_commands
Browse files Browse the repository at this point in the history
  • Loading branch information
bowenliang123 committed Nov 27, 2024
1 parent 63a2c8b commit a31d968
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
17 changes: 2 additions & 15 deletions api/app_factory.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,14 @@
import os

from configs import dify_config

if not dify_config.DEBUG:
from gevent import monkey

monkey.patch_all()

import grpc.experimental.gevent

grpc.experimental.gevent.init_gevent()


from flask import Flask

from commands import register_commands
from configs import dify_config
from extensions import (
ext_app_metrics,
ext_blueprints,
ext_celery,
ext_code_based_extension,
ext_commands,
ext_compress,
ext_database,
ext_hosting_provider,
Expand Down Expand Up @@ -67,8 +55,6 @@ def create_app() -> Flask:
app = create_flask_app_with_configs()
app.secret_key = dify_config.SECRET_KEY
initialize_extensions(app)
register_commands(app)

return app


Expand All @@ -92,6 +78,7 @@ def initialize_extensions(app: Flask):
ext_sentry,
ext_proxy_fix,
ext_blueprints,
ext_commands,
]
for ext in extensions:
ext.init_app(app)
12 changes: 0 additions & 12 deletions api/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,15 +640,3 @@ def fix_app_site_missing():
break

click.echo(click.style("Fix for missing app-related sites completed successfully!", fg="green"))


def register_commands(app):
app.cli.add_command(reset_password)
app.cli.add_command(reset_email)
app.cli.add_command(reset_encrypt_key_pair)
app.cli.add_command(vdb_migrate)
app.cli.add_command(convert_to_agent_apps)
app.cli.add_command(add_qdrant_doc_id_index)
app.cli.add_command(create_tenant)
app.cli.add_command(upgrade_db)
app.cli.add_command(fix_app_site_missing)
25 changes: 25 additions & 0 deletions api/extensions/ext_commands.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from flask import Flask


def init_app(app: Flask):
from commands import (
add_qdrant_doc_id_index,
convert_to_agent_apps,
create_tenant,
fix_app_site_missing,
reset_email,
reset_encrypt_key_pair,
reset_password,
upgrade_db,
vdb_migrate,
)

app.cli.add_command(reset_password)
app.cli.add_command(reset_email)
app.cli.add_command(reset_encrypt_key_pair)
app.cli.add_command(vdb_migrate)
app.cli.add_command(convert_to_agent_apps)
app.cli.add_command(add_qdrant_doc_id_index)
app.cli.add_command(create_tenant)
app.cli.add_command(upgrade_db)
app.cli.add_command(fix_app_site_missing)

0 comments on commit a31d968

Please sign in to comment.