gabriel / musehub public
entrypoint.sh bash
68 lines 2.5 KB
Raw
sha256:1ccb8409daa5aabe577bd26d11b56ed12f3376d64011d0e75a247e81211a66ee docs(mwp4/phase5): tick Phase 5 checkboxes, close musehub#109 Sonnet 4.6 20 days ago
1 #!/bin/sh
2 set -e
3
4 # /tmp/devpkgs is a writable site-packages directory for dev bind-mount installs.
5 # It's added to PYTHONPATH so packages installed here are importable.
6 DEVPKGS=/tmp/devpkgs
7 mkdir -p "$DEVPKGS"
8 export PYTHONPATH="$DEVPKGS${PYTHONPATH:+:$PYTHONPATH}"
9
10 # Install the muse package if the dev volume mount is present.
11 # Copy to /tmp first so setuptools can write egg-info without hitting the
12 # read-only bind-mount.
13 if [ -f /muse/pyproject.toml ]; then
14 echo "Muse volume detected — installing muse..."
15 mkdir -p /tmp/muse-install
16 tar -C /muse --exclude='./.muse' -cf - . | tar -xf - -C /tmp/muse-install
17 pip install /tmp/muse-install --target "$DEVPKGS" --no-deps --quiet 2>/dev/null || true
18 rm -rf /tmp/muse-install
19 fi
20
21 # Install the muse_contracts package if the dev volume mount is present.
22 # Provides shared cross-repo type contracts (IssueRecord, ProposalRecord, etc.).
23 # Copy to /tmp first so setuptools can write egg-info without hitting the
24 # read-only bind-mount.
25 if [ -f /src/contracts/pyproject.toml ]; then
26 echo "Contracts volume detected — installing muse_contracts..."
27 cp -r /src/contracts /tmp/muse-contracts-install
28 pip install /tmp/muse-contracts-install --target "$DEVPKGS" --no-deps --quiet 2>/dev/null || true
29 rm -rf /tmp/muse-contracts-install
30 fi
31
32 # If a command was passed (e.g., "alembic upgrade head" from the deploy script),
33 # run it directly without starting the server.
34 if [ $# -gt 0 ]; then
35 exec "$@"
36 fi
37
38 # Blue-green deploys run migrations as a one-off before starting the new slot,
39 # so the new container starts clean without re-running them.
40 # Set SKIP_MIGRATIONS=1 in the new container to skip this step.
41 if [ "${SKIP_MIGRATIONS:-0}" = "1" ]; then
42 echo "SKIP_MIGRATIONS=1 — skipping alembic (already run by deploy script)"
43 else
44 echo "Running database migrations..."
45 alembic upgrade head
46 fi
47
48 echo "Starting background worker..."
49 python3 -m musehub.worker &
50
51 echo "Starting MuseHub..."
52 if [ -f /tls/localhost.crt ] && [ -f /tls/localhost.key ]; then
53 echo "TLS cert found — starting uvicorn with HTTPS"
54 exec uvicorn musehub.main:app \
55 --host 0.0.0.0 \
56 --port 1337 \
57 --proxy-headers \
58 --ssl-certfile /tls/localhost.crt \
59 --ssl-keyfile /tls/localhost.key \
60 --workers "${UVICORN_WORKERS:-4}"
61 else
62 echo "No TLS cert — starting uvicorn with HTTP/1.1 cleartext"
63 exec uvicorn musehub.main:app \
64 --host 0.0.0.0 \
65 --port 1337 \
66 --proxy-headers \
67 --workers "${UVICORN_WORKERS:-4}"
68 fi
File History 2 commits
sha256:1ccb8409daa5aabe577bd26d11b56ed12f3376d64011d0e75a247e81211a66ee docs(mwp4/phase5): tick Phase 5 checkboxes, close musehub#109 Sonnet 4.6 20 days ago
sha256:2c523da45351334b5c4dbefed4dc3dd553b3faa8737a4e6caf301e5dc82141be test(mwp4): Phase 0 RED reproduction tests for RC-4 ordering race Sonnet 4.6 20 days ago