| Crates.io | communitas-headless |
| lib.rs | communitas-headless |
| version | 0.1.19 |
| created_at | 2025-10-18 13:36:23.225568+00 |
| updated_at | 2025-10-18 13:36:23.225568+00 |
| description | Communitas headless node and CLI - bootstrap and seed node for the network |
| homepage | https://communitas.life |
| repository | https://github.com/saorsalabs/communitas |
| max_upload_size | |
| id | 1889213 |
| size | 221,715 |
Headless daemon for running Communitas as a system service.
Communitas Headless is a daemon application that runs Communitas core without a user interface. It's designed for:
# Download latest release
wget https://github.com/saorsalabs/communitas/releases/latest/communitas-headless
# Make executable
chmod +x communitas-headless
# Move to system path
sudo mv communitas-headless /usr/local/bin/
cargo install --path communitas-headless
# Homebrew (macOS)
brew install saorsalabs/tap/communitas-headless
# APT (Debian/Ubuntu) - coming soon
apt install communitas-headless
Create /etc/communitas/headless.toml:
[daemon]
api_port = 9090
api_host = "127.0.0.1"
data_dir = "/var/lib/communitas"
log_level = "info"
[identity]
four_words = "ocean-forest-moon-star"
display_name = "Headless Bot"
device_name = "Server-01"
auto_connect = true
[network]
bootstrap_nodes = [
"bootstrap.communitas.network:8080",
"bootstrap-eu.communitas.network:8080"
]
enable_mdns = false
[storage]
backup_enabled = true
backup_interval = 3600 # seconds
backup_path = "/var/backups/communitas"
[webhooks]
enabled = true
url = "https://your-app.com/webhooks/communitas"
secret = "your-webhook-secret"
events = ["message", "presence", "channel"]
[logging]
format = "json"
output = "file"
file_path = "/var/log/communitas/headless.log"
rotate_size = "100MB"
rotate_count = 5
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:
sudo systemctl enable communitas
sudo systemctl start communitas
sudo systemctl status communitas
Create ~/Library/LaunchAgents/com.saorsalabs.communitas.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.saorsalabs.communitas</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/communitas-headless</string>
<string>--config</string>
<string>/Users/you/.config/communitas/headless.toml</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>StandardOutPath</key>
<string>/Users/you/Library/Logs/communitas.log</string>
<key>StandardErrorPath</key>
<string>/Users/you/Library/Logs/communitas-error.log</string>
</dict>
</plist>
Enable and start:
launchctl load ~/Library/LaunchAgents/com.saorsalabs.communitas.plist
launchctl start com.saorsalabs.communitas
# Via curl
curl -X POST http://localhost:9090/rpc \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "method": "status", "id": 1}'
# Via Python
import requests
def call_rpc(method, params=None):
response = requests.post('http://localhost:9090/rpc', json={
'jsonrpc': '2.0',
'method': method,
'params': params or {},
'id': 1
})
return response.json()['result']
# Get status
status = call_rpc('status')
print(status)
status - Get daemon statusinfo - Get identity and network informationshutdown - Gracefully shutdown daemonmessage.send - Send a message
{
"channel_id": "ch_123",
"content": "Hello!",
"recipients": ["ocean-forest-moon-star"]
}
message.list - List messages
{
"channel_id": "ch_123",
"limit": 50,
"offset": 0
}
channel.create - Create a channelchannel.list - List channelschannel.join - Join a channelchannel.leave - Leave a channelidentity.get - Get current identityidentity.list_contacts - List contactsidentity.add_contact - Add a contactWhen enabled, the daemon will send HTTP POST requests to the configured webhook URL for events:
{
"event": "message:new",
"timestamp": "2025-10-15T12:34:56Z",
"signature": "sha256=...",
"data": {
"id": "msg_123",
"channel_id": "ch_456",
"content": "Hello",
"sender": "ocean-forest-moon-star",
"timestamp": "2025-10-15T12:34:56Z"
}
}
Webhooks are signed with HMAC-SHA256:
import hmac
import hashlib
def verify_webhook(payload, signature, secret):
expected = hmac.new(
secret.encode(),
payload.encode(),
hashlib.sha256
).hexdigest()
return hmac.compare_digest(f"sha256={expected}", signature)
#!/usr/bin/env python3
"""
Simple echo bot using Communitas Headless
"""
import requests
import time
RPC_URL = 'http://localhost:9090/rpc'
def rpc_call(method, params=None):
response = requests.post(RPC_URL, json={
'jsonrpc': '2.0',
'method': method,
'params': params or {},
'id': 1
})
return response.json().get('result')
def echo_bot():
last_message_id = None
while True:
# Get recent messages
messages = rpc_call('message.list', {
'limit': 10,
'after': last_message_id
})
for msg in messages:
if msg['id'] == last_message_id:
continue
# Echo the message
if not msg['content'].startswith('Bot:'):
rpc_call('message.send', {
'channel_id': msg['channel_id'],
'content': f"Bot: {msg['content']}"
})
last_message_id = msg['id']
time.sleep(1)
if __name__ == '__main__':
echo_bot()
Prometheus metrics available at http://localhost:9090/metrics
Key metrics:
communitas_messages_sent_totalcommunitas_messages_received_totalcommunitas_peers_connectedcommunitas_rpc_requests_totalcommunitas_uptime_secondscurl http://localhost:9090/health
Returns:
{
"status": "healthy",
"uptime": 3600,
"identity": "ocean-forest-moon-star",
"peers_connected": 42,
"version": "0.1.17"
}
cargo build -p communitas-headless --release
cargo test -p communitas-headless
cargo run -p communitas-headless -- --config test-config.toml
# Check logs
journalctl -u communitas -f # systemd
tail -f /var/log/communitas/headless.log
# Verify configuration
communitas-headless --config /etc/communitas/headless.toml --validate
systemctl status communitasnetstat -tlnp | grep 9090communitas userSee ../../docs/development/contributing.md
Dual-licensed under AGPL-3.0-or-later and commercial license.