mirror of
https://github.com/RunLit/Bambu-Run.git
synced 2026-06-22 14:09:04 +01:00
Native setup and Downsample data (#4)
* PrinterDataAPIView downsample * filament usage chart now works without day constraint * One command native setup * add setup timezone verification and link * added wipe off instructions * setup default to port 80 * user selectable port number with default to 80 * skip superuser creation if exists * auto install iptables if not available * wipe out instructions updated
This commit is contained in:
15
native/bambu-run-collector.service
Normal file
15
native/bambu-run-collector.service
Normal file
@@ -0,0 +1,15 @@
|
||||
[Unit]
|
||||
Description=Bambu-Run MQTT Collector
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=exec
|
||||
WorkingDirectory={{REPO_DIR}}
|
||||
EnvironmentFile={{REPO_DIR}}/.env
|
||||
Environment=DJANGO_SETTINGS_MODULE=standalone.settings
|
||||
ExecStart={{VENV_DIR}}/bin/python standalone/manage.py bambu_collector
|
||||
Restart=on-failure
|
||||
RestartSec=10
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
15
native/bambu-run-web.service
Normal file
15
native/bambu-run-web.service
Normal file
@@ -0,0 +1,15 @@
|
||||
[Unit]
|
||||
Description=Bambu-Run Web Dashboard
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=exec
|
||||
WorkingDirectory={{REPO_DIR}}
|
||||
EnvironmentFile={{REPO_DIR}}/.env
|
||||
Environment=DJANGO_SETTINGS_MODULE=standalone.settings
|
||||
ExecStart={{VENV_DIR}}/bin/gunicorn standalone.wsgi:application --bind 0.0.0.0:8000 --workers {{WORKERS}} --timeout 120
|
||||
Restart=on-failure
|
||||
RestartSec=5
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
58
native/bambu-run.sh
Executable file
58
native/bambu-run.sh
Executable file
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env bash
|
||||
# Bambu-Run convenience wrapper
|
||||
# Usage: ./native/bambu-run.sh {start|stop|restart|status|logs|update}
|
||||
set -euo pipefail
|
||||
|
||||
REPO_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
VENV_DIR="$REPO_DIR/.venv"
|
||||
MANAGE="$VENV_DIR/bin/python $REPO_DIR/standalone/manage.py"
|
||||
SERVICES="bambu-run-web.service bambu-run-collector.service"
|
||||
|
||||
case "${1:-help}" in
|
||||
start)
|
||||
systemctl --user start $SERVICES
|
||||
echo "Bambu-Run started."
|
||||
;;
|
||||
stop)
|
||||
systemctl --user stop $SERVICES
|
||||
echo "Bambu-Run stopped."
|
||||
;;
|
||||
restart)
|
||||
systemctl --user restart $SERVICES
|
||||
echo "Bambu-Run restarted."
|
||||
;;
|
||||
status)
|
||||
systemctl --user status $SERVICES --no-pager
|
||||
;;
|
||||
logs)
|
||||
journalctl --user -u bambu-run-web -u bambu-run-collector -f --no-hostname
|
||||
;;
|
||||
update)
|
||||
echo "Pulling latest code..."
|
||||
cd "$REPO_DIR" && git pull
|
||||
|
||||
echo "Installing dependencies..."
|
||||
"$VENV_DIR/bin/pip" install --quiet ".[standalone]"
|
||||
|
||||
echo "Running migrations..."
|
||||
$MANAGE migrate --noinput
|
||||
|
||||
echo "Collecting static files..."
|
||||
$MANAGE collectstatic --noinput --clear 2>/dev/null
|
||||
|
||||
echo "Restarting services..."
|
||||
systemctl --user restart $SERVICES
|
||||
|
||||
echo "Update complete."
|
||||
;;
|
||||
help|*)
|
||||
echo "Usage: $0 {start|stop|restart|status|logs|update}"
|
||||
echo
|
||||
echo " start Start web + collector services"
|
||||
echo " stop Stop web + collector services"
|
||||
echo " restart Restart web + collector services"
|
||||
echo " status Show service status"
|
||||
echo " logs Tail live logs (Ctrl+C to stop)"
|
||||
echo " update Pull latest code, install deps, migrate, restart"
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user