daemon

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 16, 2026 License: MIT Imports: 46 Imported by: 0

Documentation

Overview

Package daemon implements The Forge's background daemon process.

The daemon runs the main orchestration loop:

  • Polls anvils for ready beads (via poller)
  • Spawns Smith workers (via worker pool)
  • Monitors PRs (via Bellows)
  • Writes a PID file for lifecycle management
  • Logs to ~/.forge/logs/daemon.log

Index

Constants

View Source
const (
	// PIDFileName is the name of the PID file within ~/.forge/.
	PIDFileName = "forge.pid"

	// LogDir is the directory for daemon logs within ~/.forge/.
	LogDir = "logs"

	// LogFileName is the daemon log filename.
	LogFileName = "daemon.log"

	// DefaultPollInterval is the default interval between bead polls.
	DefaultPollInterval = 30 * time.Second

	// GracefulTimeout is how long to wait for workers to finish on shutdown.
	GracefulTimeout = 60 * time.Second

	// MaxDispatchFailures is the number of consecutive dispatch failures before
	// a bead is circuit-broken (marked needs_human). This prevents a single
	// poison bead from consuming capacity every poll cycle.
	MaxDispatchFailures = 3
)

Variables

This section is empty.

Functions

func IsRunning

func IsRunning() (int, bool)

IsRunning checks whether a daemon process is already running by reading the PID file and checking if the process is alive.

func Stop

func Stop() error

Stop sends a graceful shutdown signal to the running daemon. On Windows, syscall.SIGINT is not supported, so we use an IPC "shutdown" command instead. On Unix we send SIGINT directly.

Types

type Daemon

type Daemon struct {
	// contains filtered or unexported fields
}

Daemon is the main Forge orchestration daemon.

func New

func New(cfg *config.Config) (*Daemon, error)

New creates a new daemon instance.

func (*Daemon) BroadcastEvent

func (d *Daemon) BroadcastEvent(eventType string, data any)

BroadcastEvent sends an event to all connected IPC clients.

func (*Daemon) Run

func (d *Daemon) Run(ctx context.Context) error

Run starts the daemon's main loop. It blocks until ctx is cancelled or a shutdown signal is received.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL