emberd is a small CLI for managing systemd units (start/stop/restart/reload/status/logs) and viewing unit logs.
Table of contents
- Prerequisites
- Build
- Install
- Usage
- Running emberd as a systemd service
- Permissions & best practices
- Development
- Repository
- Go 1.20+ (to build the binary)
- A Linux host using systemd with
systemctlandjournalctl
Build the binary from the repository root:
go build -o emberd ./...Copy the built binary to a system path (example):
sudo cp emberd /usr/local/bin/
sudo chown root:root /usr/local/bin/emberd
sudo chmod 0755 /usr/local/bin/emberdCommon commands:
- Start a unit:
emberd start nginx.service - Stop a unit:
emberd stop nginx.service - Restart:
emberd restart nginx.service - Reload (if supported):
emberd reload nginx.service - Show status:
emberd status nginx.service - Tail logs:
emberd logs nginx.service -f - Show last N lines:
emberd logs nginx.service -n 200
You can also pass the unit via flag: emberd start -u nginx.service
Run emberd --help for full command help.
emberd is mainly a CLI for interactive and automated service management. If you need a daemon that tails logs continuously, create a systemd unit that runs emberd logs <unit> -f.
Example unit file (save as /etc/systemd/system/emberd-logs-nginx.service):
[Unit]
Description=emberd log tailer for nginx
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/emberd logs nginx.service -f
Restart=always
RestartSec=5
# Consider running as a non-root user if possible
User=root
[Install]
WantedBy=multi-user.targetEnable and start it:
sudo systemctl daemon-reload
sudo systemctl enable --now emberd-logs-nginx.service
sudo journalctl -u emberd-logs-nginx.service -f- Managing system services requires privileges. Use
sudoor run asrootfor system units. - For user-scoped units/journals, use
systemctl --userandjournalctl --userinstead. - Prefer ad-hoc CLI usage or scripted automation over running a privileged long-lived process.
- If non-root operators need to control services, use Polkit rules to grant specific permissions rather than running everything as root.
Helpful make targets are provided in the repository:
make build # build the binary
make install # copy to /usr/local/bin (Makefile uses `install`)
make fmt # run gofmt
make vet # run go vet
make tidy # go mod tidy