Skip to content

Commit

Permalink
implement cron job for resign_whitelist in main.py
Browse files Browse the repository at this point in the history
  • Loading branch information
alexboden committed Dec 21, 2024
1 parent 23051b3 commit c25b5d9
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions server/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ async def fastapi_lifespan(app: FastAPI):
scheduler.start()
# Run housekeeping every minute
scheduler.add_job(housekeeping, CronTrigger.from_crontab("* * * * *"))
# Run resign_whitelist daily
scheduler.add_job(resign_whitelist, CronTrigger.from_crontab("0 0 * * *"))
yield
finally:
scheduler.shutdown()
Expand All @@ -145,6 +147,17 @@ async def fastapi_lifespan(app: FastAPI):
fastapi_app = WATcloudFastAPI(logger=logger, lifespan=fastapi_lifespan)
transaction_lock = Lock()

def resign_whitelist():
"""
Function to run the cvmfs_server resign command.
"""
logger.info("Running cvmfs_server resign")
res = subprocess.run(["cvmfs_server", "resign"], check=True)
if res.returncode != 0:
logger.error(f"Failed to run cvmfs_server resign (exit code: {res.returncode})")
else:
logger.info("Successfully ran cvmfs_server resign")

@fastapi_app.post("/repos/{repo_name}")
async def upload(repo_name: str, file: UploadFile, overwrite: bool = False, ttl_s: int = DEFAULT_TTL_S):
logger.info(f"Uploading file: {file.filename} (content_type: {file.content_type}, ttl_s: {ttl_s}) to repo: {repo_name}")
Expand Down

0 comments on commit c25b5d9

Please sign in to comment.