Systemd Service Deployment
For continuous background execution and network availability, homectl can run as a Linux systemd service.
Automated Setup
Section titled “Automated Setup”The repository provides an installation script in scripts/install.sh:
chmod +x ./scripts/install.sh./scripts/install.shUnit File Configuration
Section titled “Unit File Configuration”The installer places the service unit at /etc/systemd/system/homectl.service:
[Unit]Description=homectl Smart Home API ServerAfter=network.target
[Service]ExecStart=/usr/local/bin/homectl serve --port 8086 --ui /usr/local/share/homectl/uiRestart=alwaysUser=homectl-userEnvironment=XDG_CONFIG_HOME=/home/homectl-user/.config
[Install]WantedBy=multi-user.targetCritical Directives:
Section titled “Critical Directives:”ExecStart: Startshomectl servepointing to the shared UI asset directory. By default, it binds to0.0.0.0(all network interfaces).Restart=always: Automatically recovers if network connectivity drops or the host restarts.Environment=XDG_CONFIG_HOME: Ensures the service uses the correct user directory where certificates andconfig.jsonare stored.
Network Isolation & Tailscale Binding:
Section titled “Network Isolation & Tailscale Binding:”Because the API server does not require authentication, binding to 0.0.0.0 exposes endpoints to all devices on the local subnet. For enhanced security:
- Loopback only (
127.0.0.1): Append--host 127.0.0.1toExecStartif using a local reverse proxy (like Nginx or Caddy) with authentication. - Tailscale overlay (
100.x.y.z): Append-H 100.x.y.ztoExecStartto restrict API access strictly to your authenticated Tailscale tailnet. - Persistent configuration: Set
"api_host": "100.x.y.z"in~/.config/homectl/config.json.
Service Management Commands
Section titled “Service Management Commands”# Start the daemonsudo systemctl start homectl
# Stop the daemonsudo systemctl stop homectl
# Restart after code update or configuration editsudo systemctl restart homectl
# Check status and healthsystemctl status homectl
# Follow live log outputjournalctl -u homectl -f
# Review logs since yesterdayjournalctl -u homectl --since "yesterday"