changes to mobile styling in modal view, complete reword of backend worker system
This commit is contained in:
@@ -13,6 +13,9 @@ import sqlite3
|
||||
db = SQLAlchemy()
|
||||
migrate = Migrate()
|
||||
|
||||
# Celery instance - will be configured with app context in create_app
|
||||
celery = None
|
||||
|
||||
|
||||
# =============================================================================
|
||||
# CLI Commands
|
||||
@@ -25,6 +28,34 @@ def version_check_command():
|
||||
from app.utils.version_migration import check_and_run_migrations
|
||||
check_and_run_migrations()
|
||||
|
||||
|
||||
@click.command("celery-worker")
|
||||
@click.option('--queues', '-Q', default='scan,import,thumbnail,sidecar,default',
|
||||
help='Comma-separated list of queues to consume')
|
||||
@click.option('--concurrency', '-c', default=2, type=int,
|
||||
help='Number of worker processes')
|
||||
@with_appcontext
|
||||
def celery_worker_command(queues, concurrency):
|
||||
"""Start a Celery worker for processing import tasks."""
|
||||
from app.celery_app import celery as celery_app
|
||||
celery_app.worker_main([
|
||||
'worker',
|
||||
f'--queues={queues}',
|
||||
f'--concurrency={concurrency}',
|
||||
'--loglevel=info'
|
||||
])
|
||||
|
||||
|
||||
@click.command("celery-beat")
|
||||
@with_appcontext
|
||||
def celery_beat_command():
|
||||
"""Start Celery Beat scheduler for periodic tasks."""
|
||||
from app.celery_app import celery as celery_app
|
||||
celery_app.worker_main([
|
||||
'beat',
|
||||
'--loglevel=info'
|
||||
])
|
||||
|
||||
@event.listens_for(Engine, "connect")
|
||||
def set_sqlite_pragma(dbapi_connection, connection_record):
|
||||
# Only apply to SQLite connections
|
||||
@@ -54,5 +85,13 @@ def create_app(config_class='config.Config'):
|
||||
|
||||
# Register CLI commands
|
||||
app.cli.add_command(version_check_command)
|
||||
app.cli.add_command(celery_worker_command)
|
||||
app.cli.add_command(celery_beat_command)
|
||||
|
||||
# Initialize Celery with Flask app context
|
||||
from app.celery_app import make_celery
|
||||
global celery
|
||||
celery = make_celery(app)
|
||||
app.celery = celery
|
||||
|
||||
return app
|
||||
|
||||
Reference in New Issue
Block a user