Skip to content

aluminumio/busl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Aluminumio Busl - Log Streaming Service

A simple but powerful log streaming service for Platform-as-a-Service (PaaS) deployments. Busl provides real-time log streaming from applications to web interfaces via HTTP/2.

Architecture

Busl Log Streaming Architecture

github.com/aluminumio/busl busl server (pubsub service) busltee package (library) busltee command (CLI tool) /streams/ HTTP/2 transport HTTP API imports uses Your Application log-stream (wrapper) imports Data Flow Command Web Viewers stdout/stderr HTTP POST streams to

Components

1. Busl Server

A pubsub (publish/subscribe) service that:

  • Creates and manages log streams
  • Accepts log data via HTTP POST
  • Streams data to multiple subscribers via Server-Sent Events (SSE)
  • Supports HTTP/2 for efficient streaming

2. Busltee Package/Command

A Go library and CLI tool that:

  • Captures stdout/stderr from processes
  • Streams output to busl server endpoints
  • Handles retries and connection management
  • Works like Unix tee but for network streaming

3. Log-Stream Wrapper

A lightweight wrapper that:

  • Parses environment variables for stream configuration
  • Executes commands while streaming their output
  • Used in PaaS deployments for build/release logging

Quick Start

Running the Busl Server

# Clone and build
git clone https://github.com/aluminumio/busl
cd busl
go build ./cmd/busl

# Run the server
export PORT=5001
export STORAGE_URL="redis://localhost:6379"  # Optional: for persistence
./busl

Streaming Logs from a Command

# Create a stream
export STREAM_ID=$(uuidgen)
curl -X PUT http://localhost:5001/streams/$STREAM_ID

# Stream a command's output
./busltee http://localhost:5001/streams/$STREAM_ID -- your-command arg1 arg2

# Or use the log-stream wrapper with environment variables
export ALUMINUMIO_STREAM_URL_MYAPP=http://localhost:5001/streams/$STREAM_ID
./log-stream -- your-command arg1 arg2

Viewing Logs in a Web Browser

Create a simple HTML file to view streams:

<!DOCTYPE html>
<html>
<head>
    <title>Log Viewer</title>
    <style>
        body { font-family: monospace; background: #1e1e1e; color: #d4d4d4; }
        #logs { white-space: pre-wrap; padding: 20px; }
        .error { color: #f48771; }
        .info { color: #4ec9b0; }
    </style>
</head>
<body>
    <h1>Live Log Stream</h1>
    <div id="logs"></div>
    <script>
        const streamId = new URLSearchParams(window.location.search).get('stream');
        const logs = document.getElementById('logs');
        
        if (streamId) {
            const evtSource = new EventSource(`http://localhost:5001/streams/${streamId}`);
            
            evtSource.onmessage = function(e) {
                const line = document.createElement('div');
                line.textContent = e.data;
                if (e.data.includes('ERROR')) line.className = 'error';
                if (e.data.includes('INFO')) line.className = 'info';
                logs.appendChild(line);
                window.scrollTo(0, document.body.scrollHeight);
            };
            
            evtSource.onerror = function(e) {
                logs.appendChild(document.createTextNode('\n[Connection Error]\n'));
            };
        } else {
            logs.textContent = 'Please provide ?stream=STREAM_ID in the URL';
        }
    </script>
</body>
</html>

Save as viewer.html and open with: file:///path/to/viewer.html?stream=YOUR_STREAM_ID

Complete Setup Guide

1. Server Configuration

Environment variables for the busl server:

# Required
PORT=5001                          # HTTP port to listen on

# Optional
STORAGE_URL=redis://localhost:6379 # Redis URL for persistence
CREDENTIALS=username:password      # Basic auth for stream creation
REQUEST_TIMEOUT=300               # Request timeout in seconds
STREAM_TIMEOUT=86400             # Stream expiry in seconds

2. Production Deployment

For production use with systemd:

[Unit]
Description=Busl Log Streaming Server
After=network.target

[Service]
Type=simple
User=busl
WorkingDirectory=/opt/busl
ExecStart=/opt/busl/busl
Restart=always
Environment="PORT=5001"
Environment="STORAGE_URL=redis://localhost:6379"
Environment="CREDENTIALS=admin:secretpassword"

[Install]
WantedBy=multi-user.target

3. Using with Your PaaS

The log-stream wrapper is designed for PaaS environments:

# In your buildpack or deployment script
export ALUMINUMIO_STREAM_URL_BUILD=https://logs.yourpaas.com/streams/$BUILD_ID
./log-stream -- make build

# For application logs
export ALUMINUMIO_STREAM_URL_APP=https://logs.yourpaas.com/streams/$APP_ID
./log-stream -- ./start-app.sh

4. Securing Streams

  • Use HTTPS in production
  • Set CREDENTIALS for basic auth on stream creation
  • Use random UUIDs for stream IDs
  • Implement rate limiting via reverse proxy
  • Set appropriate STREAM_TIMEOUT values

API Reference

Create Stream

PUT /streams/{stream-id}
Authorization: Basic base64(username:password)  # If CREDENTIALS is set

Publish to Stream

POST /streams/{stream-id}
Content-Type: text/plain

Your log data here...

Subscribe to Stream

GET /streams/{stream-id}
Accept: text/event-stream

# Or with range for resuming
GET /streams/{stream-id}
Range: bytes=1024-

Building from Source

# Build all components
make all

# Build individual components
make busl      # Server
make busltee   # CLI tool

# Run tests
make test

Architecture Benefits

  1. Scalable: HTTP/2 support for efficient multiplexing
  2. Reliable: Built-in retry logic and connection management
  3. Simple: Clean HTTP API, works with any language
  4. Flexible: Can be used standalone or integrated into larger systems
  5. Compatible: Works with standard tools (curl, EventSource, etc.)

License

MIT License - see LICENSE file for details

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages