mirror of
https://github.com/rommapp/romm.git
synced 2026-02-18 00:27:41 +01:00
refactor: enable scheduled tasks in scheduler and init scripts
This commit is contained in:
@@ -1,20 +1,23 @@
|
||||
import sentry_sdk
|
||||
from config import SENTRY_DSN
|
||||
from config import (
|
||||
ENABLE_SCHEDULED_RESCAN,
|
||||
ENABLE_SCHEDULED_UPDATE_SWITCH_TITLEDB,
|
||||
SENTRY_DSN,
|
||||
)
|
||||
from logger.logger import log
|
||||
from tasks.scan_library import scan_library_task
|
||||
from tasks.tasks import tasks_scheduler
|
||||
from tasks.update_switch_titledb import update_switch_titledb_task
|
||||
from utils import get_version
|
||||
|
||||
sentry_sdk.init(
|
||||
dsn=SENTRY_DSN,
|
||||
release="romm@" + get_version(),
|
||||
)
|
||||
sentry_sdk.init(dsn=SENTRY_DSN, release=f"romm@{get_version()}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Initialize the tasks
|
||||
scan_library_task.init()
|
||||
update_switch_titledb_task.init()
|
||||
if ENABLE_SCHEDULED_RESCAN:
|
||||
scan_library_task.init()
|
||||
if ENABLE_SCHEDULED_UPDATE_SWITCH_TITLEDB:
|
||||
update_switch_titledb_task.init()
|
||||
|
||||
log.info("Starting scheduler")
|
||||
|
||||
|
||||
@@ -6,7 +6,9 @@ set -o pipefail # treat errors in pipes as fatal
|
||||
shopt -s inherit_errexit # inherit errexit
|
||||
|
||||
# make it possible to disable the inotify watcher process
|
||||
ENABLE_RESCAN_ON_FILESYSTEM_CHANGE="${ENABLE_RESCAN_ON_FILESYSTEM_CHANGE:="true"}"
|
||||
ENABLE_RESCAN_ON_FILESYSTEM_CHANGE="${ENABLE_RESCAN_ON_FILESYSTEM_CHANGE:="false"}"
|
||||
ENABLE_SCHEDULED_RESCAN="${ENABLE_SCHEDULED_RESCAN:="false"}"
|
||||
ENABLE_SCHEDULED_UPDATE_SWITCH_TITLEDB="${ENABLE_SCHEDULED_UPDATE_SWITCH_TITLEDB:="false"}"
|
||||
|
||||
# Set INIT_DEBUG to false if not set by docker env
|
||||
# (this env var is currently undocumented and usually just needed for development purposes)
|
||||
@@ -186,19 +188,24 @@ while ! ((exited)); do
|
||||
# Start nginx if we dont have a corresponding PID file
|
||||
watchdog_process_pid bin nginx
|
||||
|
||||
# only start the watcher.py if we actually want to use the rescan on fs change feature
|
||||
# Start background worker processes
|
||||
debug_log "Starting worker"
|
||||
# Start worker if we dont have a corresponding PID file
|
||||
watchdog_process_pid python worker
|
||||
|
||||
# only start the scheduler.py if enabled
|
||||
if [[ ${ENABLE_SCHEDULED_RESCAN} == "true" || ${ENABLE_SCHEDULED_UPDATE_SWITCH_TITLEDB} == "true" ]]; then
|
||||
debug_log "Starting scheduler"
|
||||
# Start scheduler if we dont have a corresponding PID file
|
||||
watchdog_process_pid python scheduler
|
||||
fi
|
||||
|
||||
# only start the watcher.py if enabled
|
||||
if [[ ${ENABLE_RESCAN_ON_FILESYSTEM_CHANGE} == "true" ]]; then
|
||||
# Start watcher if we dont have a corresponding PID file
|
||||
watchdog_process_pid python watcher
|
||||
fi
|
||||
|
||||
# Start background worker processes
|
||||
debug_log "Starting worker and scheduler"
|
||||
# Start worker if we dont have a corresponding PID file
|
||||
watchdog_process_pid python worker
|
||||
# Start scheduler if we dont have a corresponding PID file
|
||||
watchdog_process_pid python scheduler
|
||||
|
||||
# check for died processes every 5 seconds
|
||||
sleep 5
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user