Apply Venus OS best practices across all services

- Standardize multilog to s25000 n4 (~100KB cap) to prevent filling /data
- Use VeDbusService register=False + deferred register() in dbus-generator-ramp and dbus-vrm-history
- Add @exit_on_error decorator to template GLib callback
- Document best practices in README and template README

Made-with: Cursor
This commit is contained in:
2026-03-16 18:40:54 +00:00
parent 9756538f16
commit dd566f6975
15 changed files with 45 additions and 12 deletions

View File

@@ -34,6 +34,15 @@ Update these for your service:
| `/Connected` | int | Connection status (0/1) |
| `/Settings/Template/Enabled` | int | Enable/disable via settings |
## Venus OS Best Practices
The template follows these [Venus OS wiki](https://github.com/victronenergy/venus/wiki) guidelines:
- **`register=False`** -- `VeDbusService` is created with `register=False`, paths are added, then `register()` is called to prevent race conditions with consumers.
- **`@exit_on_error`** -- Applied to the `GLib.timeout_add` callback so unhandled exceptions crash the process instead of silently dropping the callback.
- **`daemon=True`** -- Set on background threads so they don't prevent process exit.
- **multilog** -- Log size capped at `s25000 n4` (~100KB) to avoid filling the `/data` partition.
## Checklist
- [ ] Unique service name in `config.py` (`com.victronenergy.yourservice`)
@@ -41,4 +50,6 @@ Update these for your service:
- [ ] All file references updated in `service/run`, `install.sh`, `build-package.sh`
- [ ] Custom D-Bus paths added
- [ ] Settings paths updated
- [ ] `@exit_on_error` on all `GLib.timeout_add` callbacks
- [ ] Background threads use `daemon=True`
- [ ] README replaced with your own documentation

View File

@@ -20,6 +20,7 @@ import time
sys.path.insert(1, os.path.join(os.path.dirname(__file__), 'ext', 'velib_python'))
from vedbus import VeDbusService # noqa: E402
from ve_utils import exit_on_error # noqa: E402
from settingsdevice import SettingsDevice # noqa: E402
import dbus # noqa: E402
from gi.repository import GLib # noqa: E402
@@ -84,6 +85,7 @@ class TemplateService:
self._running = True
GLib.timeout_add(MAIN_LOOP_INTERVAL_MS, self._update)
@exit_on_error
def _update(self):
"""Called every MAIN_LOOP_INTERVAL_MS. Return True to keep running."""
if not self._running:

View File

@@ -1,2 +1,2 @@
#!/bin/sh
exec multilog t s99999 n8 /var/log/dbus-template
exec multilog t s25000 n4 /var/log/dbus-template