bambuddy.service 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # BamBuddy Systemd Service Template
  2. #
  3. # INSTALLATION:
  4. # 1. Copy this file to /etc/systemd/system/bambuddy.service
  5. # 2. Replace placeholders:
  6. # - INSTALL_PATH: Where BamBuddy is installed (e.g., /opt/bambuddy)
  7. # - SERVICE_USER: User to run as (e.g., bambuddy)
  8. # - DATA_DIR: Data directory (e.g., /opt/bambuddy/data)
  9. # - LOG_DIR: Log directory (e.g., /opt/bambuddy/logs)
  10. # 3. Run: sudo systemctl daemon-reload
  11. # 4. Run: sudo systemctl enable bambuddy
  12. # 5. Run: sudo systemctl start bambuddy
  13. #
  14. # Or use the install script: ./install/install.sh
  15. #
  16. [Unit]
  17. Description=BamBuddy - Bambu Lab Print Management
  18. Documentation=https://github.com/maziggy/bambuddy
  19. After=network.target
  20. [Service]
  21. Type=simple
  22. User=SERVICE_USER
  23. Group=SERVICE_USER
  24. WorkingDirectory=INSTALL_PATH
  25. # Environment file (optional - created by install script)
  26. EnvironmentFile=-INSTALL_PATH/.env
  27. # Use virtual environment
  28. Environment="PATH=INSTALL_PATH/venv/bin:/usr/local/bin:/usr/bin:/bin"
  29. # Server configuration
  30. ExecStart=INSTALL_PATH/venv/bin/uvicorn backend.app.main:app --host 0.0.0.0 --port ${PORT:-8000}
  31. # Restart policy
  32. Restart=on-failure
  33. RestartSec=5
  34. # Graceful shutdown
  35. TimeoutStopSec=10
  36. # Kill zombie ffmpeg processes (timelapse processing)
  37. ExecStartPre=-/usr/bin/pkill -9 -f "ffmpeg.*bambuddy"
  38. ExecStopPost=-/usr/bin/pkill -9 -f "ffmpeg.*bambuddy"
  39. # Logging
  40. StandardOutput=journal
  41. StandardError=journal
  42. SyslogIdentifier=bambuddy
  43. # Security hardening
  44. NoNewPrivileges=true
  45. PrivateTmp=true
  46. ProtectSystem=strict
  47. ProtectHome=true
  48. ReadWritePaths=DATA_DIR LOG_DIR INSTALL_PATH
  49. [Install]
  50. WantedBy=multi-user.target