fix duplication run
This commit is contained in:
parent
423b77033c
commit
3ab4467423
@ -36,9 +36,15 @@ class MatchNotFoundError(Exception):
|
|||||||
|
|
||||||
|
|
||||||
class SeriesApp:
|
class SeriesApp:
|
||||||
def __init__(self, directory_to_search: str):
|
_initialization_count = 0 # Track how many times initialization has been called
|
||||||
|
|
||||||
|
def __init__(self, directory_to_search: str):
|
||||||
|
SeriesApp._initialization_count += 1
|
||||||
|
|
||||||
|
# Only show initialization message for the first instance
|
||||||
|
if SeriesApp._initialization_count <= 1:
|
||||||
print("Please wait while initializing...")
|
print("Please wait while initializing...")
|
||||||
|
|
||||||
self.progress = None
|
self.progress = None
|
||||||
self.directory_to_search = directory_to_search
|
self.directory_to_search = directory_to_search
|
||||||
self.Loaders = Loaders()
|
self.Loaders = Loaders()
|
||||||
|
|||||||
@ -177,9 +177,6 @@ def init_series_app():
|
|||||||
series_app = SeriesApp(directory_to_search)
|
series_app = SeriesApp(directory_to_search)
|
||||||
return series_app
|
return series_app
|
||||||
|
|
||||||
# Initialize the app on startup
|
|
||||||
init_series_app()
|
|
||||||
|
|
||||||
# Register WebSocket handlers
|
# Register WebSocket handlers
|
||||||
register_socketio_handlers(socketio)
|
register_socketio_handlers(socketio)
|
||||||
|
|
||||||
@ -288,7 +285,14 @@ def cleanup_on_exit():
|
|||||||
# All routes have been moved to separate blueprint files in web/routes/
|
# All routes have been moved to separate blueprint files in web/routes/
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
# Only run initialization and logging setup in the main process
|
||||||
|
# This prevents duplicate initialization when Flask debug reloader starts
|
||||||
|
|
||||||
|
# Initialize the series app
|
||||||
|
init_series_app()
|
||||||
|
|
||||||
|
# Only configure logging if we're not in the reloader child process
|
||||||
|
if os.environ.get('WERKZEUG_RUN_MAIN') != 'true':
|
||||||
# Configure enhanced logging system
|
# Configure enhanced logging system
|
||||||
try:
|
try:
|
||||||
from server.infrastructure.logging.config import get_logger, logging_config
|
from server.infrastructure.logging.config import get_logger, logging_config
|
||||||
|
|||||||
@ -195,3 +195,85 @@
|
|||||||
2025-09-29 14:09:28 - WARNING - werkzeug - _log - * Debugger is active!
|
2025-09-29 14:09:28 - WARNING - werkzeug - _log - * Debugger is active!
|
||||||
2025-09-29 14:09:47 - INFO - root - cleanup_on_exit - Application cleanup completed
|
2025-09-29 14:09:47 - INFO - root - cleanup_on_exit - Application cleanup completed
|
||||||
2025-09-29 14:09:48 - INFO - root - cleanup_on_exit - Application cleanup completed
|
2025-09-29 14:09:48 - INFO - root - cleanup_on_exit - Application cleanup completed
|
||||||
|
2025-09-29 14:15:55 - INFO - __main__ - <module> - Enhanced logging system initialized
|
||||||
|
2025-09-29 14:15:55 - INFO - __main__ - <module> - Starting Aniworld Flask server...
|
||||||
|
2025-09-29 14:15:55 - INFO - __main__ - <module> - Anime directory: \\sshfs.r\ubuntu@192.168.178.43\media\serien\Serien
|
||||||
|
2025-09-29 14:15:55 - INFO - __main__ - <module> - Log level: INFO
|
||||||
|
2025-09-29 14:15:55 - INFO - __main__ - <module> - Scheduled operations disabled
|
||||||
|
2025-09-29 14:15:55 - INFO - __main__ - <module> - Server will be available at http://localhost:5000
|
||||||
|
2025-09-29 14:16:02 - INFO - __main__ - <module> - Enhanced logging system initialized
|
||||||
|
2025-09-29 14:16:02 - INFO - __main__ - <module> - Starting Aniworld Flask server...
|
||||||
|
2025-09-29 14:16:02 - INFO - __main__ - <module> - Anime directory: \\sshfs.r\ubuntu@192.168.178.43\media\serien\Serien
|
||||||
|
2025-09-29 14:16:02 - INFO - __main__ - <module> - Log level: INFO
|
||||||
|
2025-09-29 14:16:02 - INFO - __main__ - <module> - Scheduled operations disabled
|
||||||
|
2025-09-29 14:16:02 - INFO - __main__ - <module> - Server will be available at http://localhost:5000
|
||||||
|
2025-09-29 14:16:02 - WARNING - werkzeug - _log - * Debugger is active!
|
||||||
|
2025-09-29 14:16:24 - INFO - root - cleanup_on_exit - Application cleanup completed
|
||||||
|
2025-09-29 14:16:28 - INFO - __main__ - <module> - Enhanced logging system initialized
|
||||||
|
2025-09-29 14:16:28 - INFO - __main__ - <module> - Starting Aniworld Flask server...
|
||||||
|
2025-09-29 14:16:28 - INFO - __main__ - <module> - Anime directory: \\sshfs.r\ubuntu@192.168.178.43\media\serien\Serien
|
||||||
|
2025-09-29 14:16:28 - INFO - __main__ - <module> - Log level: INFO
|
||||||
|
2025-09-29 14:16:28 - INFO - __main__ - <module> - Scheduled operations disabled
|
||||||
|
2025-09-29 14:16:28 - INFO - __main__ - <module> - Server will be available at http://localhost:5000
|
||||||
|
2025-09-29 14:16:28 - WARNING - werkzeug - _log - * Debugger is active!
|
||||||
|
2025-09-29 14:16:42 - INFO - root - cleanup_on_exit - Application cleanup completed
|
||||||
|
2025-09-29 14:16:47 - INFO - __main__ - <module> - Enhanced logging system initialized
|
||||||
|
2025-09-29 14:16:47 - INFO - __main__ - <module> - Starting Aniworld Flask server...
|
||||||
|
2025-09-29 14:16:47 - INFO - __main__ - <module> - Anime directory: \\sshfs.r\ubuntu@192.168.178.43\media\serien\Serien
|
||||||
|
2025-09-29 14:16:47 - INFO - __main__ - <module> - Log level: INFO
|
||||||
|
2025-09-29 14:16:47 - INFO - __main__ - <module> - Scheduled operations disabled
|
||||||
|
2025-09-29 14:16:47 - INFO - __main__ - <module> - Server will be available at http://localhost:5000
|
||||||
|
2025-09-29 14:16:47 - WARNING - werkzeug - _log - * Debugger is active!
|
||||||
|
2025-09-29 14:17:01 - INFO - root - cleanup_on_exit - Application cleanup completed
|
||||||
|
2025-09-29 14:17:05 - INFO - __main__ - <module> - Enhanced logging system initialized
|
||||||
|
2025-09-29 14:17:05 - INFO - __main__ - <module> - Starting Aniworld Flask server...
|
||||||
|
2025-09-29 14:17:05 - INFO - __main__ - <module> - Anime directory: \\sshfs.r\ubuntu@192.168.178.43\media\serien\Serien
|
||||||
|
2025-09-29 14:17:05 - INFO - __main__ - <module> - Log level: INFO
|
||||||
|
2025-09-29 14:17:05 - INFO - __main__ - <module> - Scheduled operations disabled
|
||||||
|
2025-09-29 14:17:05 - INFO - __main__ - <module> - Server will be available at http://localhost:5000
|
||||||
|
2025-09-29 14:17:05 - WARNING - werkzeug - _log - * Debugger is active!
|
||||||
|
2025-09-29 14:17:11 - INFO - root - cleanup_on_exit - Application cleanup completed
|
||||||
|
2025-09-29 14:17:15 - INFO - __main__ - <module> - Enhanced logging system initialized
|
||||||
|
2025-09-29 14:17:15 - INFO - __main__ - <module> - Starting Aniworld Flask server...
|
||||||
|
2025-09-29 14:17:15 - INFO - __main__ - <module> - Anime directory: \\sshfs.r\ubuntu@192.168.178.43\media\serien\Serien
|
||||||
|
2025-09-29 14:17:15 - INFO - __main__ - <module> - Log level: INFO
|
||||||
|
2025-09-29 14:17:15 - INFO - __main__ - <module> - Scheduled operations disabled
|
||||||
|
2025-09-29 14:17:15 - INFO - __main__ - <module> - Server will be available at http://localhost:5000
|
||||||
|
2025-09-29 14:17:15 - WARNING - werkzeug - _log - * Debugger is active!
|
||||||
|
2025-09-29 14:17:24 - INFO - root - cleanup_on_exit - Application cleanup completed
|
||||||
|
2025-09-29 14:17:29 - INFO - __main__ - <module> - Enhanced logging system initialized
|
||||||
|
2025-09-29 14:17:29 - INFO - __main__ - <module> - Starting Aniworld Flask server...
|
||||||
|
2025-09-29 14:17:29 - INFO - __main__ - <module> - Anime directory: \\sshfs.r\ubuntu@192.168.178.43\media\serien\Serien
|
||||||
|
2025-09-29 14:17:29 - INFO - __main__ - <module> - Log level: INFO
|
||||||
|
2025-09-29 14:17:29 - INFO - __main__ - <module> - Scheduled operations disabled
|
||||||
|
2025-09-29 14:17:29 - INFO - __main__ - <module> - Server will be available at http://localhost:5000
|
||||||
|
2025-09-29 14:17:29 - WARNING - werkzeug - _log - * Debugger is active!
|
||||||
|
2025-09-29 14:17:38 - INFO - __main__ - <module> - Enhanced logging system initialized
|
||||||
|
2025-09-29 14:17:38 - INFO - __main__ - <module> - Starting Aniworld Flask server...
|
||||||
|
2025-09-29 14:17:38 - INFO - __main__ - <module> - Anime directory: \\sshfs.r\ubuntu@192.168.178.43\media\serien\Serien
|
||||||
|
2025-09-29 14:17:38 - INFO - __main__ - <module> - Log level: INFO
|
||||||
|
2025-09-29 14:17:38 - INFO - __main__ - <module> - Scheduled operations disabled
|
||||||
|
2025-09-29 14:17:38 - INFO - __main__ - <module> - Server will be available at http://localhost:5000
|
||||||
|
2025-09-29 14:17:42 - INFO - __main__ - <module> - Enhanced logging system initialized
|
||||||
|
2025-09-29 14:17:42 - INFO - __main__ - <module> - Starting Aniworld Flask server...
|
||||||
|
2025-09-29 14:17:42 - INFO - __main__ - <module> - Anime directory: \\sshfs.r\ubuntu@192.168.178.43\media\serien\Serien
|
||||||
|
2025-09-29 14:17:42 - INFO - __main__ - <module> - Log level: INFO
|
||||||
|
2025-09-29 14:17:42 - INFO - __main__ - <module> - Scheduled operations disabled
|
||||||
|
2025-09-29 14:17:42 - INFO - __main__ - <module> - Server will be available at http://localhost:5000
|
||||||
|
2025-09-29 14:17:42 - WARNING - werkzeug - _log - * Debugger is active!
|
||||||
|
2025-09-29 14:18:02 - INFO - root - cleanup_on_exit - Application cleanup completed
|
||||||
|
2025-09-29 14:18:03 - INFO - root - cleanup_on_exit - Application cleanup completed
|
||||||
|
2025-09-29 14:18:16 - INFO - __main__ - <module> - Enhanced logging system initialized
|
||||||
|
2025-09-29 14:18:16 - INFO - __main__ - <module> - Starting Aniworld Flask server...
|
||||||
|
2025-09-29 14:18:16 - INFO - __main__ - <module> - Anime directory: \\sshfs.r\ubuntu@192.168.178.43\media\serien\Serien
|
||||||
|
2025-09-29 14:18:16 - INFO - __main__ - <module> - Log level: INFO
|
||||||
|
2025-09-29 14:18:16 - INFO - __main__ - <module> - Scheduled operations disabled
|
||||||
|
2025-09-29 14:18:16 - INFO - __main__ - <module> - Server will be available at http://localhost:5000
|
||||||
|
2025-09-29 14:18:57 - INFO - root - cleanup_on_exit - Application cleanup completed
|
||||||
|
2025-09-29 14:19:04 - INFO - __main__ - <module> - Enhanced logging system initialized
|
||||||
|
2025-09-29 14:19:04 - INFO - __main__ - <module> - Starting Aniworld Flask server...
|
||||||
|
2025-09-29 14:19:04 - INFO - __main__ - <module> - Anime directory: \\sshfs.r\ubuntu@192.168.178.43\media\serien\Serien
|
||||||
|
2025-09-29 14:19:04 - INFO - __main__ - <module> - Log level: INFO
|
||||||
|
2025-09-29 14:19:04 - INFO - __main__ - <module> - Scheduled operations disabled
|
||||||
|
2025-09-29 14:19:04 - INFO - __main__ - <module> - Server will be available at http://localhost:5000
|
||||||
|
2025-09-29 14:19:06 - INFO - root - cleanup_on_exit - Application cleanup completed
|
||||||
|
|||||||
@ -84,6 +84,22 @@ def init_series_app():
|
|||||||
series_app = SeriesApp(directory_to_search)
|
series_app = SeriesApp(directory_to_search)
|
||||||
return series_app
|
return series_app
|
||||||
|
|
||||||
|
def get_series_app():
|
||||||
|
"""Get the current series app instance, initializing if needed."""
|
||||||
|
global series_app
|
||||||
|
if series_app is None:
|
||||||
|
# Try to get it from the main app module first
|
||||||
|
try:
|
||||||
|
import app
|
||||||
|
if hasattr(app, 'series_app') and app.series_app is not None:
|
||||||
|
series_app = app.series_app
|
||||||
|
return series_app
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
# If not available, initialize it
|
||||||
|
init_series_app()
|
||||||
|
return series_app
|
||||||
|
|
||||||
# Import socketio instance - this will need to be passed from app.py
|
# Import socketio instance - this will need to be passed from app.py
|
||||||
socketio = None
|
socketio = None
|
||||||
|
|
||||||
@ -131,7 +147,8 @@ def update_directory():
|
|||||||
def get_series():
|
def get_series():
|
||||||
"""Get all series data."""
|
"""Get all series data."""
|
||||||
try:
|
try:
|
||||||
if series_app is None or series_app.List is None:
|
current_series_app = get_series_app()
|
||||||
|
if current_series_app is None or current_series_app.List is None:
|
||||||
return jsonify({
|
return jsonify({
|
||||||
'status': 'success',
|
'status': 'success',
|
||||||
'series': [],
|
'series': [],
|
||||||
@ -141,7 +158,7 @@ def get_series():
|
|||||||
|
|
||||||
# Get series data
|
# Get series data
|
||||||
series_data = []
|
series_data = []
|
||||||
for serie in series_app.List.GetList():
|
for serie in current_series_app.List.GetList():
|
||||||
series_data.append({
|
series_data.append({
|
||||||
'folder': serie.folder,
|
'folder': serie.folder,
|
||||||
'name': serie.name or serie.folder,
|
'name': serie.name or serie.folder,
|
||||||
@ -192,14 +209,15 @@ def search_series():
|
|||||||
}), 400
|
}), 400
|
||||||
|
|
||||||
# Check if series_app is available
|
# Check if series_app is available
|
||||||
if series_app is None:
|
current_series_app = get_series_app()
|
||||||
|
if current_series_app is None:
|
||||||
return jsonify({
|
return jsonify({
|
||||||
'status': 'error',
|
'status': 'error',
|
||||||
'message': 'Series application not initialized'
|
'message': 'Series application not initialized'
|
||||||
}), 500
|
}), 500
|
||||||
|
|
||||||
# Perform the search
|
# Perform the search
|
||||||
search_results = series_app.search(query)
|
search_results = current_series_app.search(query)
|
||||||
|
|
||||||
# Format results for the frontend
|
# Format results for the frontend
|
||||||
results = []
|
results = []
|
||||||
@ -819,9 +837,10 @@ def process_locks_status():
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
# Initialize the series app when the blueprint is loaded
|
# Initialize the series app when needed (now handled in main app.py)
|
||||||
try:
|
# Commenting out module-level initialization to prevent duplicate initialization
|
||||||
init_series_app()
|
# try:
|
||||||
except Exception as e:
|
# init_series_app()
|
||||||
print(f"Failed to initialize series app in API blueprint: {e}")
|
# except Exception as e:
|
||||||
series_app = None
|
# print(f"Failed to initialize series app in API blueprint: {e}")
|
||||||
|
# series_app = None
|
||||||
Loading…
x
Reference in New Issue
Block a user