Skip to content

Commit

Permalink
Add exit code checks to subprocess.run
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-z committed Oct 13, 2024
1 parent f112684 commit 1de2d5e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions server/src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,17 @@ def init_cvmfs_repo(repo_name: str):
Path("/var/www/cvmfs").symlink_to("/srv/cvmfs")

# Enable apache2 modules
res = subprocess.run(["a2enmod", "headers", "expires", "proxy", "proxy_http"])
res = subprocess.run(["a2enmod", "headers", "expires", "proxy", "proxy_http"], check=True)
if res.returncode != 0:
sys.exit(f"Failed to enable apache2 modules (exit code: {res.returncode})")

# Start apache2 service
res = subprocess.run(["service", "apache2", "start"])
res = subprocess.run(["service", "apache2", "start"], check=True)
if res.returncode != 0:
sys.exit(f"Failed to start apache2 service (exit code: {res.returncode})")

# Run cvmfs_server mkfs
res = subprocess.run(["cvmfs_server", "mkfs", "-o", "root", "-Z", "none", repo_name])
res = subprocess.run(["cvmfs_server", "mkfs", "-o", "root", "-Z", "none", repo_name], check=True)
if res.returncode != 0:
sys.exit(f"Failed to run cvmfs_server mkfs (exit code: {res.returncode})")

Expand All @@ -54,7 +54,7 @@ def init_cvmfs_repo(repo_name: str):
gateway_repo_config_path.write_text(json.dumps(gateway_repo_config, indent=4))

# Restart cvmfs-gateway
res = subprocess.run(["service", "cvmfs-gateway", "restart"])
res = subprocess.run(["service", "cvmfs-gateway", "restart"], check=True)
if res.returncode != 0:
sys.exit(f"Failed to restart cvmfs-gateway service (exit code: {res.returncode})")

Expand Down

0 comments on commit 1de2d5e

Please sign in to comment.