added scripts to worker
This commit is contained in:
+14
-5
@@ -12,6 +12,7 @@ from fastapi import FastAPI
|
||||
|
||||
DB_FILE = Path("/opt/appfactory/data/appfactory/appfactory.db")
|
||||
TOOLS_DIR = Path("/tools")
|
||||
SCRIPTS_DIR = Path("/opt/appfactory/workspace/appfactory-tools/scripts")
|
||||
MAINTENANCE_DIR = Path("/opt/appfactory/workspace/appfactory-tools/maintenance")
|
||||
ALERTS_DIR = Path("/opt/appfactory/workspace/appfactory-tools/alerts")
|
||||
|
||||
@@ -387,14 +388,22 @@ def command_for_job(job: dict):
|
||||
|
||||
validate_script_name(script_name)
|
||||
|
||||
script_path = MAINTENANCE_DIR / script_name
|
||||
candidate_dirs = [
|
||||
MAINTENANCE_DIR,
|
||||
SCRIPTS_DIR,
|
||||
]
|
||||
|
||||
if not script_path.exists():
|
||||
script_path = None
|
||||
|
||||
for base_dir in candidate_dirs:
|
||||
candidate = base_dir / script_name
|
||||
if candidate.exists() and candidate.is_file():
|
||||
script_path = candidate
|
||||
break
|
||||
|
||||
if script_path is None:
|
||||
raise ValueError(f"Script not found: {script_name}")
|
||||
|
||||
if not script_path.is_file():
|
||||
raise ValueError(f"Script is not a file: {script_name}")
|
||||
|
||||
return [str(script_path)]
|
||||
|
||||
if job_type == "run_alert_script":
|
||||
|
||||
Reference in New Issue
Block a user