Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
alexboden committed Dec 21, 2024
1 parent c25b5d9 commit bc026e4
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions server/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,17 +147,6 @@ 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 Expand Up @@ -439,6 +428,15 @@ def housekeeping():
logger.info(f"Housekeeping completed. Took {housekeeping_end - housekeeping_start:.2f}s")
return {"message": "Housekeeping completed", "housekeeping_time_s": housekeeping_end - housekeeping_start}

@app.command()
@fastapi_app.post("/resign")
def resign_whitelist():
"""
Function to run the cvmfs_server resign command.
"""
logger.info("Running cvmfs_server resign")
subprocess.run(["cvmfs_server", "resign"], check=True)

@app.command()
def start_server(port: int = 81):
uvicorn.run(fastapi_app, host="0.0.0.0", port=port)
Expand Down

0 comments on commit bc026e4

Please sign in to comment.