chore: remove test installer and update template escape sequence

- Remove tester installer from playcmds factory
- Update template to use ^^ escape for @[params] annotation
- Format various model and actions files
This commit is contained in:
Timur Gordon
2025-11-19 15:51:20 +01:00
parent a5c4b8f6f8
commit 86da2cd435
12 changed files with 145 additions and 142 deletions

View File

@@ -110,7 +110,7 @@ fn upload() ! {
}
@@[params]
^^[params]
pub struct InstallArgs {
pub mut:
reset bool

View File

@@ -11,7 +11,7 @@ import os
fn startupcmd() ![]startupmanager.ZProcessNewArgs {
mut cfg := get()!
mut res := []startupmanager.ZProcessNewArgs{}
res << startupmanager.ZProcessNewArgs{
name: 'redis'
cmd: 'redis-server ${configfilepath(cfg)}'
@@ -37,9 +37,9 @@ fn start_pre() ! {
if running()! {
return
}
mut cfg := get()!
// Ensure data directory exists with proper permissions before configuring
osal.execute_silent('mkdir -p ${cfg.datadir}')!
if core.is_linux()! {
@@ -47,13 +47,13 @@ fn start_pre() ! {
osal.execute_silent('chown -R redis:redis ${cfg.datadir}')!
osal.execute_silent('chmod 755 ${cfg.datadir}')!
}
// Configure redis before starting (applies template)
configure()!
// Kill any existing redis processes
osal.process_kill_recursive(name: 'redis-server')!
// On macOS, start redis with daemonize (not via startupmanager)
if core.platform()! == .osx {
osal.exec(cmd: 'redis-server ${configfilepath(cfg)} --daemonize yes')!
@@ -108,9 +108,9 @@ pub fn redis_install(args RedisInstall) ! {
console.print_debug('Redis already running on port ${args.port}')
return
}
console.print_header('install redis')
// Install Redis package if not already installed
if !installed()! {
if core.is_linux()! {
@@ -119,12 +119,12 @@ pub fn redis_install(args RedisInstall) ! {
osal.package_install('redis')! // macOS, Alpine, Arch, etc.
}
}
// Create data directory with correct permissions
osal.execute_silent('mkdir -p ${args.datadir}')!
osal.execute_silent('chown -R redis:redis ${args.datadir}') or {}
osal.execute_silent('chmod 755 ${args.datadir}') or {}
// Configure and start Redis
start(args)!
}
@@ -145,10 +145,10 @@ pub fn start(args RedisInstall) ! {
console.print_debug('Redis already running on port ${args.port}')
return
}
// Write Redis configuration file
configure_with_args(args)!
// Kill any existing Redis processes (including package auto-started ones)
osal.process_kill_recursive(name: 'redis-server')!
@@ -172,7 +172,7 @@ pub fn start(args RedisInstall) ! {
osal.exec(cmd: 'redis-server ${configfilepath(args)} --daemonize yes')!
}
}
// Wait for Redis to be ready
for _ in 0 .. 100 {
if check(args) {
@@ -181,7 +181,7 @@ pub fn start(args RedisInstall) ! {
}
time.sleep(100)
}
return error('Redis did not start properly after 10 seconds - could not ping on port ${args.port}')
}

View File

@@ -12,7 +12,7 @@ import os
fn (self &Coordinator) startupcmd() ![]startupmanager.ZProcessNewArgs {
mut res := []startupmanager.ZProcessNewArgs{}
res << startupmanager.ZProcessNewArgs{
name: 'coordinator'
cmd: '${self.binary_path} --redis-addr ${self.redis_addr} --api-http-port ${self.http_port} --api-ws-port ${self.ws_port}'
@@ -28,7 +28,11 @@ fn (self &Coordinator) startupcmd() ![]startupmanager.ZProcessNewArgs {
fn (self &Coordinator) running_check() !bool {
// Check if the process is running by checking the HTTP port
res := osal.exec(cmd: 'curl -fsSL http://127.0.0.1:${self.http_port} || exit 1', stdout: false, raise_error: false)!
res := osal.exec(
cmd: 'curl -fsSL http://127.0.0.1:${self.http_port} || exit 1'
stdout: false
raise_error: false
)!
return res.exit_code == 0
}
@@ -53,7 +57,7 @@ fn (self &Coordinator) installed() !bool {
if !binary.exists() {
return false
}
return true
}
@@ -71,7 +75,6 @@ fn upload() ! {
// )!
}
@[params]
pub struct InstallArgs {
pub mut:
@@ -88,7 +91,7 @@ fn (mut self Coordinator) install(args InstallArgs) ! {
pub fn build_coordinator() ! {
console.print_header('build coordinator')
println('📦 Starting coordinator build process...\n')
// Use default config instead of getting from factory
println(' Initializing configuration...')
mut cfg := Coordinator{}
@@ -97,7 +100,7 @@ pub fn build_coordinator() ! {
println(' - Redis address: ${cfg.redis_addr}')
println(' - HTTP port: ${cfg.http_port}')
println(' - WS port: ${cfg.ws_port}\n')
// Ensure rust is installed
println('Step 1/3: Checking Rust dependency...')
if !osal.cmd_exists('rustc') {
@@ -109,7 +112,7 @@ pub fn build_coordinator() ! {
res := osal.exec(cmd: 'rustc --version', stdout: false, raise_error: false)!
println('Rust is already installed: ${res.output.trim_space()}\n')
}
// Clone or get the repository
println('Step 2/3: Cloning/updating horus repository...')
// Use the configured repo_path or default coderoot
@@ -119,42 +122,42 @@ pub fn build_coordinator() ! {
pull: true
reset: false
)!
// Update the path to the actual cloned repo
cfg.repo_path = repo.path()
println(' Repository ready at: ${cfg.repo_path}\n')
// Build the coordinator binary from the horus workspace
println('Step 3/3: Building coordinator binary...')
println('WARNING: This may take several minutes (compiling Rust code)...')
println('Running: cargo build -p hero-coordinator --release\n')
cmd := 'cd ${cfg.repo_path} && . ~/.cargo/env && RUSTFLAGS="-A warnings" cargo build -p hero-coordinator --release'
osal.execute_stdout(cmd)!
println('\n Build completed successfully')
// Ensure binary directory exists and copy the binary
println('📁 Preparing binary directory: ${cfg.binary_path}')
mut binary_path_obj := pathlib.get(cfg.binary_path)
osal.dir_ensure(binary_path_obj.path_dir())!
// Copy the built binary to the configured location
source_binary := '${cfg.repo_path}/target/release/coordinator'
println('📋 Copying binary from: ${source_binary}')
println('📋 Copying binary to: ${cfg.binary_path}')
mut source_file := pathlib.get_file(path: source_binary)!
source_file.copy(dest: cfg.binary_path, rsync: false)!
println('\n🎉 Coordinator built successfully!')
println('📍 Binary location: ${cfg.binary_path}')
}
fn (mut self Coordinator) build() ! {
console.print_header('build coordinator')
println('Building coordinator binary from ${self}')
// Ensure Redis is installed and running (required for coordinator)
console.print_debug('Checking if Redis is installed and running...')
redis_check := osal.exec(cmd: 'redis-cli -c -p 6379 ping', stdout: false, raise_error: false)!
@@ -170,7 +173,7 @@ fn (mut self Coordinator) build() ! {
} else {
console.print_debug('Redis is already running')
}
// Ensure rust is installed
console.print_debug('Checking if Rust is installed...')
mut rust_installer := rust.get()!
@@ -181,7 +184,7 @@ fn (mut self Coordinator) build() ! {
} else {
console.print_debug('Rust is already installed: ${res.output.trim_space()}')
}
// Clone or get the repository
console.print_debug('Cloning/updating horus repository...')
mut gs := gittools.new()!
@@ -190,42 +193,42 @@ fn (mut self Coordinator) build() ! {
pull: true
reset: false
)!
// Update the path to the actual cloned repo
self.repo_path = repo.path()
set(self)!
console.print_debug('Repository path: ${self.repo_path}')
// Build the coordinator binary from the horus workspace
console.print_header('Building coordinator binary (this may take several minutes ${self.repo_path})...')
console.print_debug('Running: cargo build -p hero-coordinator --release')
console.print_debug('Build output:')
cmd := 'cd ${self.repo_path} && . ~/.cargo/env && RUSTFLAGS="-A warnings" cargo build -p hero-coordinator --release'
osal.execute_stdout(cmd)!
console.print_debug('Build completed successfully')
// Ensure binary directory exists and copy the binary
console.print_header('Preparing binary directory: ${self.binary_path}')
mut binary_path_obj := pathlib.get(self.binary_path)
osal.dir_ensure(binary_path_obj.path_dir())!
// Copy the built binary to the configured location
source_binary := '${self.repo_path}/target/release/coordinator'
console.print_debug('Copying binary from: ${source_binary}')
console.print_debug('Copying binary to: ${self.binary_path}')
mut source_file := pathlib.get_file(path: source_binary)!
source_file.copy(dest: self.binary_path, rsync: false)!
console.print_header('coordinator built successfully at ${self.binary_path}')
}
fn (mut self Coordinator) destroy() ! {
self.stop()!
osal.process_kill_recursive(name: 'coordinator')!
// Remove the built binary
osal.rm(self.binary_path)!
}

View File

@@ -14,13 +14,13 @@ const default = true
@[heap]
pub struct Coordinator {
pub mut:
name string = 'default'
binary_path string = os.join_path(os.home_dir(), 'hero/bin/coordinator')
redis_addr string = '127.0.0.1:6379'
http_port int = 8081
ws_port int = 9653
log_level string = 'info'
repo_path string = '/root/code/git.ourworld.tf/herocode/horus'
name string = 'default'
binary_path string = os.join_path(os.home_dir(), 'hero/bin/coordinator')
redis_addr string = '127.0.0.1:6379'
http_port int = 8081
ws_port int = 9653
log_level string = 'info'
repo_path string = '/root/code/git.ourworld.tf/herocode/horus'
}
// your checking & initialization code if needed
@@ -30,7 +30,7 @@ fn obj_init(mycfg_ Coordinator) !Coordinator {
mycfg.name = 'default'
}
if mycfg.binary_path == '' {
mycfg.binary_path = os.join_path(os.home_dir(),'hero/bin/coordinator')
mycfg.binary_path = os.join_path(os.home_dir(), 'hero/bin/coordinator')
}
if mycfg.redis_addr == '' {
mycfg.redis_addr = '127.0.0.1:6379'

View File

@@ -11,7 +11,7 @@ import os
fn (self &Herorunner) startupcmd() ![]startupmanager.ZProcessNewArgs {
mut res := []startupmanager.ZProcessNewArgs{}
res << startupmanager.ZProcessNewArgs{
name: 'herorunner'
cmd: '${self.binary_path} --redis-addr ${self.redis_addr}'
@@ -52,7 +52,7 @@ fn (self &Herorunner) installed() !bool {
if !binary.exists() {
return false
}
return true
}
@@ -66,7 +66,6 @@ fn ulist_get() !ulist.UList {
fn upload() ! {
}
@[params]
pub struct InstallArgs {
pub mut:
@@ -81,7 +80,7 @@ fn (mut self Herorunner) install(args InstallArgs) ! {
fn (mut self Herorunner) build() ! {
console.print_header('build herorunner')
// Ensure rust is installed
console.print_debug('Checking if Rust is installed...')
mut rust_installer := rust.get()!
@@ -92,7 +91,7 @@ fn (mut self Herorunner) build() ! {
} else {
console.print_debug('Rust is already installed: ${res.output.trim_space()}')
}
// Clone or get the repository
console.print_debug('Cloning/updating horus repository...')
mut gs := gittools.new()!
@@ -101,40 +100,40 @@ fn (mut self Herorunner) build() ! {
pull: true
reset: false
)!
repo_path := repo.path()
console.print_debug('Repository path: ${repo_path}')
// Build the herorunner binary from the horus workspace
console.print_header('Building herorunner binary (this may take several minutes)...')
console.print_debug('Running: cargo build -p runner-hero --release')
console.print_debug('Build output:')
cmd := 'cd ${repo_path} && . ~/.cargo/env && RUSTFLAGS="-A warnings" cargo build -p runner-hero --release'
osal.execute_stdout(cmd)!
console.print_debug('Build completed successfully')
// Ensure binary directory exists and copy the binary
console.print_debug('Preparing binary directory: ${self.binary_path}')
mut binary_path_obj := pathlib.get(self.binary_path)
osal.dir_ensure(binary_path_obj.path_dir())!
// Copy the built binary to the configured location
source_binary := '${repo_path}/target/release/herorunner'
console.print_debug('Copying binary from: ${source_binary}')
console.print_debug('Copying binary to: ${self.binary_path}')
mut source_file := pathlib.get_file(path: source_binary)!
source_file.copy(dest: self.binary_path, rsync: false)!
console.print_header('herorunner built successfully at ${self.binary_path}')
}
fn (mut self Herorunner) destroy() ! {
self.stop()!
osal.process_kill_recursive(name: 'herorunner')!
// Remove the built binary
osal.rm(self.binary_path)!
}

View File

@@ -14,10 +14,10 @@ const default = true
@[heap]
pub struct Herorunner {
pub mut:
name string = 'default'
binary_path string = os.join_path(os.home_dir(), 'hero/bin/herorunner')
redis_addr string = '127.0.0.1:6379'
log_level string = 'info'
name string = 'default'
binary_path string = os.join_path(os.home_dir(), 'hero/bin/herorunner')
redis_addr string = '127.0.0.1:6379'
log_level string = 'info'
}
// your checking & initialization code if needed

View File

@@ -11,7 +11,7 @@ import os
fn (self &Osirisrunner) startupcmd() ![]startupmanager.ZProcessNewArgs {
mut res := []startupmanager.ZProcessNewArgs{}
res << startupmanager.ZProcessNewArgs{
name: 'runner_osiris'
cmd: '${self.binary_path} --redis-addr ${self.redis_addr}'
@@ -52,7 +52,7 @@ fn (self &Osirisrunner) installed() !bool {
if !binary.exists() {
return false
}
return true
}
@@ -66,7 +66,6 @@ fn ulist_get() !ulist.UList {
fn upload() ! {
}
@[params]
pub struct InstallArgs {
pub mut:
@@ -81,7 +80,7 @@ fn (mut self Osirisrunner) install(args InstallArgs) ! {
fn (mut self Osirisrunner) build() ! {
console.print_header('build osirisrunner')
// Ensure rust is installed
console.print_debug('Checking if Rust is installed...')
mut rust_installer := rust.get()!
@@ -92,7 +91,7 @@ fn (mut self Osirisrunner) build() ! {
} else {
console.print_debug('Rust is already installed: ${res.output.trim_space()}')
}
// Clone or get the repository
console.print_debug('Cloning/updating horus repository...')
mut gs := gittools.new()!
@@ -101,42 +100,42 @@ fn (mut self Osirisrunner) build() ! {
pull: true
reset: false
)!
// Update the path to the actual cloned repo
self.repo_path = repo.path()
set(self)!
console.print_debug('Repository path: ${self.repo_path}')
// Build the osirisrunner binary from the horus workspace
console.print_header('Building osirisrunner binary (this may take several minutes)...')
console.print_debug('Running: cargo build -p runner-osiris --release')
console.print_debug('Build output:')
cmd := 'cd ${self.repo_path} && . ~/.cargo/env && RUSTFLAGS="-A warnings" cargo build -p runner-osiris --release'
osal.execute_stdout(cmd)!
console.print_debug('Build completed successfully')
// Ensure binary directory exists and copy the binary
console.print_debug('Preparing binary directory: ${self.binary_path}')
mut binary_path_obj := pathlib.get(self.binary_path)
osal.dir_ensure(binary_path_obj.path_dir())!
// Copy the built binary to the configured location
source_binary := '${self.repo_path}/target/release/runner_osiris'
console.print_debug('Copying binary from: ${source_binary}')
console.print_debug('Copying binary to: ${self.binary_path}')
mut source_file := pathlib.get_file(path: source_binary)!
source_file.copy(dest: self.binary_path, rsync: false)!
console.print_header('osirisrunner built successfully at ${self.binary_path}')
}
fn (mut self Osirisrunner) destroy() ! {
self.stop()!
osal.process_kill_recursive(name: 'runner_osiris')!
// Remove the built binary
osal.rm(self.binary_path)!
}

View File

@@ -14,11 +14,11 @@ const default = true
@[heap]
pub struct Osirisrunner {
pub mut:
name string = 'default'
binary_path string = os.join_path(os.home_dir(), 'hero/bin/runner_osiris')
redis_addr string = '127.0.0.1:6379'
log_level string = 'info'
repo_path string = '/root/code/git.ourworld.tf/herocode/horus'
name string = 'default'
binary_path string = os.join_path(os.home_dir(), 'hero/bin/runner_osiris')
redis_addr string = '127.0.0.1:6379'
log_level string = 'info'
repo_path string = '/root/code/git.ourworld.tf/herocode/horus'
}
// your checking & initialization code if needed

View File

@@ -11,7 +11,7 @@ import os
fn (self &Salrunner) startupcmd() ![]startupmanager.ZProcessNewArgs {
mut res := []startupmanager.ZProcessNewArgs{}
res << startupmanager.ZProcessNewArgs{
name: 'runner_sal'
cmd: '${self.binary_path} --redis-addr ${self.redis_addr}'
@@ -52,7 +52,7 @@ fn (self &Salrunner) installed() !bool {
if !binary.exists() {
return false
}
return true
}
@@ -66,7 +66,6 @@ fn ulist_get() !ulist.UList {
fn upload() ! {
}
@[params]
pub struct InstallArgs {
pub mut:
@@ -81,7 +80,7 @@ fn (mut self Salrunner) install(args InstallArgs) ! {
fn (mut self Salrunner) build() ! {
console.print_header('build salrunner')
// Ensure rust is installed
console.print_debug('Checking if Rust is installed...')
mut rust_installer := rust.get()!
@@ -92,7 +91,7 @@ fn (mut self Salrunner) build() ! {
} else {
console.print_debug('Rust is already installed: ${res.output.trim_space()}')
}
// Clone or get the repository
console.print_debug('Cloning/updating horus repository...')
mut gs := gittools.new()!
@@ -101,42 +100,42 @@ fn (mut self Salrunner) build() ! {
pull: true
reset: false
)!
// Update the path to the actual cloned repo
self.repo_path = repo.path()
set(self)!
console.print_debug('Repository path: ${self.repo_path}')
// Build the salrunner binary from the horus workspace
console.print_header('Building salrunner binary (this may take several minutes)...')
console.print_debug('Running: cargo build -p runner-sal --release')
console.print_debug('Build output:')
cmd := 'cd ${self.repo_path} && . ~/.cargo/env && RUSTFLAGS="-A warnings" cargo build -p runner-sal --release'
osal.execute_stdout(cmd)!
console.print_debug('Build completed successfully')
// Ensure binary directory exists and copy the binary
console.print_debug('Preparing binary directory: ${self.binary_path}')
mut binary_path_obj := pathlib.get(self.binary_path)
osal.dir_ensure(binary_path_obj.path_dir())!
// Copy the built binary to the configured location
source_binary := '${self.repo_path}/target/release/runner_sal'
console.print_debug('Copying binary from: ${source_binary}')
console.print_debug('Copying binary to: ${self.binary_path}')
mut source_file := pathlib.get_file(path: source_binary)!
source_file.copy(dest: self.binary_path, rsync: false)!
console.print_header('salrunner built successfully at ${self.binary_path}')
}
fn (mut self Salrunner) destroy() ! {
self.stop()!
osal.process_kill_recursive(name: 'runner_sal')!
// Remove the built binary
osal.rm(self.binary_path)!
}

View File

@@ -14,11 +14,11 @@ const default = true
@[heap]
pub struct Salrunner {
pub mut:
name string = 'default'
binary_path string = os.join_path(os.home_dir(), 'hero/bin/runner_sal')
redis_addr string = '127.0.0.1:6379'
log_level string = 'info'
repo_path string = '/root/code/git.ourworld.tf/herocode/horus'
name string = 'default'
binary_path string = os.join_path(os.home_dir(), 'hero/bin/runner_sal')
redis_addr string = '127.0.0.1:6379'
log_level string = 'info'
repo_path string = '/root/code/git.ourworld.tf/herocode/horus'
}
// your checking & initialization code if needed

View File

@@ -12,7 +12,7 @@ import os
fn (self &Supervisor) startupcmd() ![]startupmanager.ZProcessNewArgs {
mut res := []startupmanager.ZProcessNewArgs{}
res << startupmanager.ZProcessNewArgs{
name: 'supervisor'
cmd: '${self.binary_path} --redis-addr ${self.redis_addr} --api-http-port ${self.http_port} --api-ws-port ${self.ws_port}'
@@ -28,7 +28,11 @@ fn (self &Supervisor) startupcmd() ![]startupmanager.ZProcessNewArgs {
fn (self &Supervisor) running_check() !bool {
// Check if the process is running by checking the HTTP port
res := osal.exec(cmd: 'curl -fsSL http://127.0.0.1:${self.http_port} || exit 1', stdout: false, raise_error: false)!
res := osal.exec(
cmd: 'curl -fsSL http://127.0.0.1:${self.http_port} || exit 1'
stdout: false
raise_error: false
)!
return res.exit_code == 0
}
@@ -53,7 +57,7 @@ fn (self &Supervisor) installed() !bool {
if !binary.exists() {
return false
}
return true
}
@@ -71,7 +75,6 @@ fn upload() ! {
// )!
}
@[params]
pub struct InstallArgs {
pub mut:
@@ -88,7 +91,7 @@ fn (mut self Supervisor) install(args InstallArgs) ! {
pub fn build_supervisor() ! {
console.print_header('build supervisor')
println('📦 Starting supervisor build process...\n')
// Use default config instead of getting from factory
println(' Initializing configuration...')
mut cfg := Supervisor{}
@@ -97,10 +100,10 @@ pub fn build_supervisor() ! {
println(' - Redis address: ${cfg.redis_addr}')
println(' - HTTP port: ${cfg.http_port}')
println(' - WS port: ${cfg.ws_port}\n')
// Ensure Redis is installed and running (required for supervisor)
println('🔍 Step 1/4: Checking Redis dependency...')
// First check if redis-server is installed
if !osal.cmd_exists_profile('redis-server') {
println(' Redis is not installed')
@@ -110,7 +113,7 @@ pub fn build_supervisor() ! {
} else {
println(' Redis is already installed')
}
// Now check if it's running
println('🔍 Checking if Redis is running...')
redis_check := osal.exec(cmd: 'redis-cli -c -p 6379 ping', stdout: false, raise_error: false)!
@@ -122,7 +125,7 @@ pub fn build_supervisor() ! {
} else {
println(' Redis is already running\n')
}
// Ensure rust is installed
println('🔍 Step 2/4: Checking Rust dependency...')
mut rust_installer := rust.get()!
@@ -134,7 +137,7 @@ pub fn build_supervisor() ! {
} else {
println(' Rust is already installed: ${res.output.trim_space()}\n')
}
// Clone or get the repository
println('🔍 Step 3/4: Cloning/updating horus repository...')
mut gs := gittools.new()!
@@ -143,40 +146,40 @@ pub fn build_supervisor() ! {
pull: true
reset: false
)!
// Update the path to the actual cloned repo
cfg.repo_path = repo.path()
println(' Repository ready at: ${cfg.repo_path}\n')
// Build the supervisor binary from the horus workspace
println('🔍 Step 4/4: Building supervisor binary...')
println(' This may take several minutes (compiling Rust code)...')
println('📝 Running: cargo build -p hero-supervisor --release\n')
cmd := 'cd ${cfg.repo_path} && . ~/.cargo/env && RUSTFLAGS="-A warnings" cargo build -p hero-supervisor --release'
osal.execute_stdout(cmd)!
println('\n Build completed successfully')
// Ensure binary directory exists and copy the binary
println('📁 Preparing binary directory: ${cfg.binary_path}')
mut binary_path_obj := pathlib.get(cfg.binary_path)
osal.dir_ensure(binary_path_obj.path_dir())!
// Copy the built binary to the configured location
source_binary := '${cfg.repo_path}/target/release/supervisor'
println('📋 Copying binary from: ${source_binary}')
println('📋 Copying binary to: ${cfg.binary_path}')
mut source_file := pathlib.get_file(path: source_binary)!
source_file.copy(dest: cfg.binary_path, rsync: false)!
println('\n🎉 Supervisor built successfully!')
println('📍 Binary location: ${cfg.binary_path}')
}
fn (mut self Supervisor) build() ! {
console.print_header('build supervisor')
// Ensure Redis is installed and running (required for supervisor)
console.print_debug('Checking if Redis is installed and running...')
redis_check := osal.exec(cmd: 'redis-cli -c -p 6379 ping', stdout: false, raise_error: false)!
@@ -192,7 +195,7 @@ fn (mut self Supervisor) build() ! {
} else {
console.print_debug('Redis is already running')
}
// Ensure rust is installed
console.print_debug('Checking if Rust is installed...')
mut rust_installer := rust.get()!
@@ -203,7 +206,7 @@ fn (mut self Supervisor) build() ! {
} else {
console.print_debug('Rust is already installed: ${res.output.trim_space()}')
}
// Clone or get the repository
console.print_debug('Cloning/updating horus repository...')
mut gs := gittools.new()!
@@ -212,42 +215,42 @@ fn (mut self Supervisor) build() ! {
pull: true
reset: false
)!
// Update the path to the actual cloned repo
self.repo_path = repo.path()
set(self)!
console.print_debug('Repository path: ${self.repo_path}')
// Build the supervisor binary from the horus workspace
console.print_header('Building supervisor binary (this may take several minutes)...')
console.print_debug('Running: cargo build -p hero-supervisor --release')
console.print_debug('Build output:')
cmd := 'cd ${self.repo_path} && . ~/.cargo/env && RUSTFLAGS="-A warnings" cargo build -p hero-supervisor --release'
osal.execute_stdout(cmd)!
console.print_debug('Build completed successfully')
// Ensure binary directory exists and copy the binary
console.print_debug('Preparing binary directory: ${self.binary_path}')
mut binary_path_obj := pathlib.get(self.binary_path)
osal.dir_ensure(binary_path_obj.path_dir())!
// Copy the built binary to the configured location
source_binary := '${self.repo_path}/target/release/supervisor'
console.print_debug('Copying binary from: ${source_binary}')
console.print_debug('Copying binary to: ${self.binary_path}')
mut source_file := pathlib.get_file(path: source_binary)!
source_file.copy(dest: self.binary_path, rsync: false)!
console.print_header('supervisor built successfully at ${self.binary_path}')
}
fn (mut self Supervisor) destroy() ! {
self.stop()!
osal.process_kill_recursive(name: 'supervisor')!
// Remove the built binary
osal.rm(self.binary_path)!
}

View File

@@ -14,13 +14,13 @@ const default = true
@[heap]
pub 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'
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'
}
// your checking & initialization code if needed