Overview
Running EdgeFlow as a systemd service ensures it starts automatically on boot and restarts if it crashes. This is the recommended approach for bare-metal installations on Raspberry Pi and other Linux systems.
Installation
First, install EdgeFlow using the install script which auto-detects your platform:
curl -fsSL https://edgx.cloud/install.sh | sudo bash
# Verify installation
edgeflow --version Create Service User
Create a dedicated user for running EdgeFlow:
# Create edgeflow user
sudo useradd -r -s /bin/false edgeflow
# Create data directory
sudo mkdir -p /var/lib/edgeflow
sudo chown edgeflow:edgeflow /var/lib/edgeflow
# Create config directory
sudo mkdir -p /etc/edgeflow
sudo chown edgeflow:edgeflow /etc/edgeflow Create Systemd Unit File
Create the service file at /etc/systemd/system/edgeflow.service:
[Unit]
Description=EdgeFlow IoT Automation Platform
Documentation=https://edgx.cloud/docs
After=network.target
[Service]
Type=simple
User=edgeflow
Group=edgeflow
# Working directory
WorkingDirectory=/var/lib/edgeflow
# Environment
Environment=EDGEFLOW_SERVER_PORT=8080
Environment=EDGEFLOW_DATABASE_PATH=/var/lib/edgeflow/edgeflow.db
Environment=EDGEFLOW_LOGGER_LEVEL=info
# Execute
ExecStart=/usr/local/bin/edgeflow serve
ExecReload=/bin/kill -HUP $MAINPID
# Restart on failure
Restart=always
RestartSec=5
# Resource limits
MemoryMax=256M
CPUQuota=80%
# Security
NoNewPrivileges=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=/var/lib/edgeflow
# Logging
StandardOutput=journal
StandardError=journal
SyslogIdentifier=edgeflow
[Install]
WantedBy=multi-user.target GPIO Access
For GPIO access on Raspberry Pi, add the user to the gpio group:
# Add edgeflow user to gpio group
sudo usermod -a -G gpio edgeflow
# Update the service file to allow device access
# Add under [Service]:
SupplementaryGroups=gpio i2c spi Enable and Start
# Reload systemd
sudo systemctl daemon-reload
# Enable service (start on boot)
sudo systemctl enable edgeflow
# Start the service
sudo systemctl start edgeflow
# Check status
sudo systemctl status edgeflow Managing the Service
| Command | Description |
|---|---|
sudo systemctl start edgeflow | Start EdgeFlow |
sudo systemctl stop edgeflow | Stop EdgeFlow |
sudo systemctl restart edgeflow | Restart EdgeFlow |
sudo systemctl status edgeflow | Check status |
sudo systemctl enable edgeflow | Enable auto-start |
sudo systemctl disable edgeflow | Disable auto-start |
Viewing Logs
# View recent logs
sudo journalctl -u edgeflow -n 50
# Follow logs in real-time
sudo journalctl -u edgeflow -f
# View logs from today
sudo journalctl -u edgeflow --since today
# View logs with errors only
sudo journalctl -u edgeflow -p err Configuration File
Create a configuration file at /etc/edgeflow/config.yaml:
# /etc/edgeflow/config.yaml
server:
port: 8080
host: 0.0.0.0
database:
path: /var/lib/edgeflow/edgeflow.db
logger:
level: info
format: json
auth:
enabled: false
modules:
network: true
gpio: true
messaging: true
database: true Update the service to use the config:
ExecStart=/usr/local/bin/edgeflow serve --config /etc/edgeflow/config.yaml Automatic Updates
Create a timer for automatic updates:
# /etc/systemd/system/edgeflow-update.timer
[Unit]
Description=EdgeFlow Update Timer
[Timer]
OnCalendar=weekly
Persistent=true
[Install]
WantedBy=timers.target # /etc/systemd/system/edgeflow-update.service
[Unit]
Description=Update EdgeFlow
[Service]
Type=oneshot
ExecStart=/usr/local/bin/edgeflow update
ExecStartPost=/bin/systemctl restart edgeflow