Skip to main content

Service Setup

The final setup step is installing the Security-Cam service. This runs the Flask API and Astro dashboard automatically on every boot, and pulls the latest code + rebuilds if anything changed.

Install the service

sudo cp /opt/security-cam/client/data/security-cam.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable security-cam.service
sudo systemctl start security-cam.service

Check that it started:

sudo systemctl status security-cam.service

After a reboot, all services start automatically. No manual steps needed.

What the service does

On every start (including boot), it runs setup/update.sh before launching the servers. This script:

  1. Runs git pull to fetch the latest code
  2. Compares the current commit with the last successful build
  3. If the code changed (or the frontend dist/ directory is missing), runs install_requirements.sh (installs deps + rebuilds frontend)
  4. Saves a stamp so it skips the rebuild on next boot if nothing changed

Each run is logged to logs/update/ with a timestamped filename. The last 20 logs are kept.

Then it starts:

  • Flask API on port 5005 - recording, system monitoring, device detection, sensor management
  • Astro dashboard on port 3000 - the web interface

To force a rebuild (e.g. after manually editing files):

sudo /opt/security-cam/setup/update.sh --force
sudo systemctl restart security-cam

Verifying everything is running

After a reboot, all services should be active:

sudo systemctl status hostapd --no-pager
sudo systemctl status mediamtx --no-pager
sudo systemctl status security-cam --no-pager
ServicePurposePort
hostapdWiFi Access Point-
mediamtxCamera stream (WebRTC/RTSP)8889 / 8554
security-camFlask API + Astro dashboard5005 / 3000

Restarting from the dashboard

You can restart or reboot directly from the web interface under Settings > System:

  • Restart services - restarts the Flask API and Astro dashboard without rebooting the Pi (~10 seconds downtime)
  • Reboot device - full system reboot (may take a few minutes if update.sh triggers a rebuild)

Both require a confirmation click and log an event to the activity timeline.

Running manually (without the service)

If you prefer to run without systemd (e.g. for debugging):

cd /opt/security-cam
./start.sh

To follow the application log in real-time:

tail -f /opt/security-cam/logs/api/security-cam.log

You can filter by subsystem using grep - see Troubleshooting > Checking logs for the full list of logger names.

note

The frontend must be built first. This is done automatically by install_requirements.sh. If you change frontend code, rebuild with:

cd /opt/security-cam/server && npm run build

Offline documentation

The full documentation is bundled with the dashboard. Once the service is running, open:

http://<pi-ip>:3000/docs/intro

This works even without internet - useful when the Pi runs in access point mode. You can also reach the docs from the sidebar in the dashboard (the book icon at the bottom).

Continue to using the dashboard to learn how to use the web interface.