diff --git a/README.md b/README.md index 4b77565..c5b2c0a 100644 --- a/README.md +++ b/README.md @@ -89,5 +89,54 @@ Once your device is configured, you can verify that its mDNS advertisement is vi - bash start_mdns.sh +## Managing Auracast systemd Services + +You can run the backend and frontend as systemd services for easier management and automatic startup on boot. + +### 1. Install the service files +Copy the provided service files to your systemd directory (requires sudo): + +```bash +sudo cp auracast-server.service /etc/systemd/system/ +sudo cp auracast-frontend.service /etc/systemd/system/ +``` + +### 2. Reload systemd +```bash +sudo systemctl daemon-reload +``` + +### 3. Enable services to start at boot +```bash +sudo systemctl enable auracast-server +sudo systemctl enable auracast-frontend +``` + +### 4. Start the services +```bash +sudo systemctl start auracast-server +sudo systemctl start auracast-frontend +``` + +### 5. Stop the services +```bash +sudo systemctl stop auracast-server +sudo systemctl stop auracast-frontend +``` + +### 6. Disable services to start at boot +```bash +sudo systemctl disable auracast-server +sudo systemctl disable auracast-frontend +``` + +### 7. Check service status +```bash +sudo systemctl status auracast-server +sudo systemctl status auracast-frontend +``` + +If you want to run the services as a specific user, edit the `User=` line in the service files accordingly. + # Known issues: - When running on a laptop there might be issues switching between usb and browser audio input since they use the same audio device \ No newline at end of file diff --git a/auracast-frontend.service b/auracast-frontend.service new file mode 100644 index 0000000..8d4d1c7 --- /dev/null +++ b/auracast-frontend.service @@ -0,0 +1,13 @@ +[Unit] +Description=Auracast Frontend HTTPS Server +After=network.target + +[Service] +Type=simple +WorkingDirectory=/home/caster/repos/bumble-auracast/src/auracast/server +ExecStart=/home/caster/repos/bumble-auracast/src/auracast/server/start_frontend_https.sh +Restart=on-failure +Environment=LOG_LEVEL=INFO + +[Install] +WantedBy=multi-user.target diff --git a/auracast-server.service b/auracast-server.service new file mode 100644 index 0000000..c33f3d3 --- /dev/null +++ b/auracast-server.service @@ -0,0 +1,15 @@ +[Unit] +Description=Auracast Backend Server +After=network.target + +[Service] +Type=simple +WorkingDirectory=/home/caster/repos/bumble-auracast +ExecStart=/home/caster/.local/bin/poetry run python src/auracast/server/multicast_server.py +Restart=on-failure +User=caster +Environment=PYTHONUNBUFFERED=1 +Environment=LOG_LEVEL=INFO + +[Install] +WantedBy=multi-user.target diff --git a/src/auracast/server/start_frontend_https.sh b/src/auracast/server/start_frontend_https.sh old mode 100644 new mode 100755 index 9bffafc..19fbd61 --- a/src/auracast/server/start_frontend_https.sh +++ b/src/auracast/server/start_frontend_https.sh @@ -30,5 +30,8 @@ echo "Device key: $KEY" echo "Using hostname: $DEVICE_HOSTNAME" echo "Using Avahi domain: $AVAHI_DOMAIN" +# Path to poetry binary +POETRY_BIN="/home/caster/.local/bin/poetry" + # Start Streamlit HTTPS server (port 443) -poetry run streamlit run multicast_frontend.py --server.port 443 --server.enableCORS false --server.enableXsrfProtection false --server.headless true --server.sslCertFile "$CERT" --server.sslKeyFile "$KEY" --browser.gatherUsageStats false +$POETRY_BIN run streamlit run multicast_frontend.py --server.port 443 --server.enableCORS false --server.enableXsrfProtection false --server.headless true --server.sslCertFile "$CERT" --server.sslKeyFile "$KEY" --browser.gatherUsageStats false