Skip to content

installers.horus.supervisor #

Supervisor Installer

A V language installer module for building and managing the Supervisor service. This installer handles the complete lifecycle of the Supervisor binary from the Horus workspace.

Features

  • Automatic Rust Installation: Installs Rust toolchain if not present
  • Git Repository Management: Clones and manages the horus repository
  • Binary Building: Compiles the supervisor binary from the horus workspace
  • Service Management: Start/stop/restart via zinit
  • Configuration: Customizable Redis, HTTP, and WebSocket ports

Quick Start

Using the Example Script

cd /root/code/github/freeflowuniverse/herolib/examples/installers/horus
./supervisor.vsh

Manual Usage

import freeflowuniverse.herolib.installers.horus.supervisor as supervisor_installer

mut supervisor := supervisor_installer.get()!
supervisor.install()!
supervisor.start()!

Configuration

!!supervisor.configure
    name:'default'
    binary_path:'/hero/var/bin/supervisor'
    redis_addr:'127.0.0.1:6379'
    http_port:8082
    ws_port:9654
    log_level:'info'
    repo_path:'/root/code/git.ourworld.tf/herocode/horus'

Configuration Fields

  • name: Instance name (default: 'default')
  • binary_path: Path where the supervisor binary will be installed (default: '/hero/var/bin/supervisor')
  • redis_addr: Redis server address (default: '127.0.0.1:6379')
  • http_port: HTTP API port (default: 8082)
  • ws_port: WebSocket API port (default: 9654)
  • log_level: Rust log level - trace, debug, info, warn, error (default: 'info')
  • repo_path: Path to clone the horus repository (default: '/root/code/git.ourworld.tf/herocode/horus')

Commands

Install

Builds the supervisor binary from the horus workspace. This will:1. Install Rust if not present2. Clone the horus repository from git.ourworld.tf3. Build the supervisor binary with cargo build -p hero-supervisor --release

hero supervisor.install

Start

Starts the supervisor service using zinit:

hero supervisor.start

Stop

Stops the running service:

hero supervisor.stop

Restart

Restarts the service:

hero supervisor.restart

Destroy

Stops the service and removes all files:

hero supervisor.destroy

Requirements

  • Dependencies:
  • Rust toolchain (automatically installed)
  • Git (for cloning repository)
  • Redis (must be running separately)
  • Mycelium (must be installed and running separately)

Architecture

The installer follows the standard herolib installer pattern:

  • supervisor_model.v: Configuration structure and initialization
  • supervisor_actions.v: Build, install, start, stop, destroy logic
  • supervisor_factory_.v: Factory pattern for instance management

Notes

  • The installer builds from source rather than downloading pre-built binaries
  • Mycelium is expected to be already installed and running in the environment
  • Redis must be running and accessible at the configured address
  • The binary is built with RUSTFLAGS="-A warnings" to suppress warnings
  • Service management uses zinit by default

Example Workflow

import freeflowuniverse.herolib.installers.horus.supervisor as sv

// Get installer instance
mut supervisor := sv.get()!

// Customize configuration
supervisor.redis_addr = '127.0.0.1:6379'
supervisor.http_port = 8082
supervisor.log_level = 'debug'
sv.set(supervisor)!

// Build and start
supervisor.install()!
supervisor.start()!

// Check status
if supervisor.running()! {
    println('Supervisor is running on port ${supervisor.http_port}')
}

// Later: cleanup
supervisor.destroy()!

fn build_supervisor #

fn build_supervisor() !

Public function to build supervisor without requiring factory/redis

fn delete #

fn delete(args ArgsGet) !

fn exists #

fn exists(args ArgsGet) !bool

does the config exists?

fn get #

fn get(args ArgsGet) !&Supervisor

fn heroscript_dumps #

fn heroscript_dumps(obj Supervisor) !string

///////////NORMALLY NO NEED TO TOUCH

fn heroscript_loads #

fn heroscript_loads(heroscript string) !Supervisor

fn list #

fn list(args ArgsList) ![]&Supervisor

if fromdb set: load from filesystem, and not from mem, will also reset what is in mem

fn new #

fn new(args ArgsGet) !&Supervisor

fn play #

fn play(mut plbook PlayBook) !

fn set #

fn set(o Supervisor) !

register the config for the future

fn switch #

fn switch(name string)

switch instance to be used for supervisor

struct ArgsGet #

@[params]
struct ArgsGet {
pub mut:
	name        string = 'default'
	binary_path string
	redis_addr  string
	http_port   int
	ws_port     int
	log_level   string
	repo_path   string
	fromdb      bool // will load from filesystem
	create      bool // default will not create if not exist
}

///////FACTORY

struct ArgsList #

@[params]
struct ArgsList {
pub mut:
	fromdb bool // will load from filesystem
}

struct InstallArgs #

@[params]
struct InstallArgs {
pub mut:
	reset bool
}

struct StartArgs #

@[params]
struct StartArgs {
pub mut:
	reset bool
}

struct Supervisor #

@[heap]
struct Supervisor {
pub mut:
	name        string = 'default'
	binary_path string = os.join_path(os.home_dir(), 'hero/bin/supervisor')
	redis_addr  string = '127.0.0.1:6379'
	http_port   int    = 8082
	ws_port     int    = 9654
	log_level   string = 'info'
	repo_path   string = '/root/code/git.ourworld.tf/herocode/horus'
}

THIS THE THE SOURCE OF THE INFORMATION OF THIS FILE, HERE WE HAVE THE CONFIG OBJECT CONFIGURED AND MODELLED

fn (Supervisor) install_start #

fn (mut self Supervisor) install_start(args InstallArgs) !

fn (Supervisor) reload #

fn (mut self Supervisor) reload() !

load from disk and make sure is properly intialized

fn (Supervisor) restart #

fn (mut self Supervisor) restart(args StartArgs) !

fn (Supervisor) running #

fn (mut self Supervisor) running() !bool

fn (Supervisor) start #

fn (mut self Supervisor) start(args StartArgs) !

fn (Supervisor) stop #

fn (mut self Supervisor) stop() !