communitas-headless-0.1.19 is not a library.
Communitas Headless
Headless daemon for running Communitas as a system service.
Overview
Communitas Headless is a daemon application that runs Communitas core without a user interface. It's designed for:
- Server deployments
- Bot applications
- Automated systems
- Background services
- Integration with other applications
Features
- System Service Integration: Supports systemd (Linux) and launchd (macOS)
- JSON-RPC API: Programmatic access to all Communitas features
- Webhook Support: Push notifications for events
- Automated Backups: Scheduled backups of state and data
- Resource Efficient: Minimal CPU and memory footprint
- Multi-Tenant: Support multiple identities/instances
Installation
From Binary
# Download latest release
# Make executable
# Move to system path
From Source
Via Package Manager
# Homebrew (macOS)
# APT (Debian/Ubuntu) - coming soon
Configuration
Create /etc/communitas/headless.toml:
[]
= 9090
= "127.0.0.1"
= "/var/lib/communitas"
= "info"
[]
= "ocean-forest-moon-star"
= "Headless Bot"
= "Server-01"
= true
[]
= [
"bootstrap.communitas.network:8080",
"bootstrap-eu.communitas.network:8080"
]
= false
[]
= true
= 3600 # seconds
= "/var/backups/communitas"
[]
= true
= "https://your-app.com/webhooks/communitas"
= "your-webhook-secret"
= ["message", "presence", "channel"]
[]
= "json"
= "file"
= "/var/log/communitas/headless.log"
= "100MB"
= 5
System Service Setup
systemd (Linux)
Create /etc/systemd/system/communitas.service:
[Unit]
Description=Communitas Headless Daemon
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=communitas
Group=communitas
ExecStart=/usr/local/bin/communitas-headless --config /etc/communitas/headless.toml
Restart=always
RestartSec=10
StandardOutput=journal
StandardError=journal
# Security
NoNewPrivileges=true
PrivateTmp=true
ProtectSystem=strict
ProtectHome=true
ReadWritePaths=/var/lib/communitas /var/log/communitas
[Install]
WantedBy=multi-user.target
Enable and start:
launchd (macOS)
Create ~/Library/LaunchAgents/com.saorsalabs.communitas.plist:
Label
com.saorsalabs.communitas
ProgramArguments
/usr/local/bin/communitas-headless
--config
/Users/you/.config/communitas/headless.toml
RunAtLoad
KeepAlive
StandardOutPath
/Users/you/Library/Logs/communitas.log
StandardErrorPath
/Users/you/Library/Logs/communitas-error.log
Enable and start:
JSON-RPC API
Connection
# Via curl
# Via Python
=
return
# Get status
=
Available Methods
Core Methods
status- Get daemon statusinfo- Get identity and network informationshutdown- Gracefully shutdown daemon
Message Methods
-
message.send- Send a message -
message.list- List messages
Channel Methods
channel.create- Create a channelchannel.list- List channelschannel.join- Join a channelchannel.leave- Leave a channel
Identity Methods
identity.get- Get current identityidentity.list_contacts- List contactsidentity.add_contact- Add a contact
Webhooks
When enabled, the daemon will send HTTP POST requests to the configured webhook URL for events:
Webhook Payload
Signature Verification
Webhooks are signed with HMAC-SHA256:
=
return
Bot Example
#!/usr/bin/env python3
"""
Simple echo bot using Communitas Headless
"""
=
=
return
= None
# Get recent messages
=
continue
# Echo the message
=
Monitoring
Metrics Endpoint
Prometheus metrics available at http://localhost:9090/metrics
Key metrics:
communitas_messages_sent_totalcommunitas_messages_received_totalcommunitas_peers_connectedcommunitas_rpc_requests_totalcommunitas_uptime_seconds
Health Check
Returns:
Development
Building
Testing
Running Locally
Troubleshooting
Service Won't Start
# Check logs
# Verify configuration
API Connection Refused
- Verify daemon is running:
systemctl status communitas - Check port is not blocked:
netstat -tlnp | grep 9090 - Review firewall rules
High Memory Usage
- Reduce backup frequency
- Limit message history retention
- Adjust peer connections in configuration
Security Best Practices
- Run as Dedicated User: Create a
communitasuser - Limit Network Access: Bind API to localhost only
- Secure Configuration: Protect config files (chmod 600)
- Regular Updates: Keep daemon updated
- Monitor Logs: Watch for suspicious activity
- Backup Encryption: Encrypt backup data
Performance
- Memory: ~50MB typical, ~200MB peak
- CPU: <5% on modern hardware
- Disk I/O: Minimal, mostly on message receipt
- Network: ~1KB/s idle, scales with activity
Contributing
See ../../docs/development/contributing.md
License
Dual-licensed under AGPL-3.0-or-later and commercial license.