From a40e1724576d98917763bd7e0262feca8c366f2c Mon Sep 17 00:00:00 2001 From: Timur Gordon <31495328+timurgordon@users.noreply.github.com> Date: Wed, 19 Nov 2025 15:09:24 +0100 Subject: [PATCH 1/4] refactor: update installer generator templates to instance-based API Update generator templates to produce installers following the new pattern: Actions template (objname_actions.vtemplate): - Convert all functions to methods on the config struct - startupcmd() -> (self &Struct) startupcmd() - running() -> (self &Struct) running_check() - start_pre/post, stop_pre/post -> methods on struct - installed(), install(), build(), destroy() -> methods on struct - Add InstallArgs struct with reset parameter - Remove get()! calls, use self instead Factory template (objname_factory_.vtemplate): - Update play() to get name parameter for all actions - Call instance methods instead of module-level functions - Add support for start_pre, start_post, stop_pre, stop_post actions - Update start(), stop(), running() to use self.method() calls - Remove duplicate InstallArgs and wrapper methods - Use self.running_check() instead of running() All newly generated installers will now follow the consistent instance-based pattern with proper lifecycle hook support. --- .../templates/objname_actions.vtemplate | 30 ++++--- .../templates/objname_factory_.vtemplate | 82 +++++++++---------- 2 files changed, 56 insertions(+), 56 deletions(-) diff --git a/lib/core/generator/generic/templates/objname_actions.vtemplate b/lib/core/generator/generic/templates/objname_actions.vtemplate index 8af55f06..5082315c 100644 --- a/lib/core/generator/generic/templates/objname_actions.vtemplate +++ b/lib/core/generator/generic/templates/objname_actions.vtemplate @@ -20,8 +20,7 @@ import incubaid.herolib.installers.lang.python import os @if args.startupmanager -fn startupcmd () ![]startupmanager.ZProcessNewArgs{ - mut installer := get()! +fn (self &${args.classname}) startupcmd() ![]startupmanager.ZProcessNewArgs { mut res := []startupmanager.ZProcessNewArgs{} //THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED // res << startupmanager.ZProcessNewArgs{ @@ -36,8 +35,7 @@ fn startupcmd () ![]startupmanager.ZProcessNewArgs{ } -fn running() !bool { - mut installer := get()! +fn (self &${args.classname}) running_check() !bool { //THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED // this checks health of ${args.name} // curl http://localhost:3333/api/v1/s --oauth2-bearer 1234 works @@ -58,19 +56,19 @@ fn running() !bool { return false } -fn start_pre()!{ +fn (self &${args.classname}) start_pre() ! { } -fn start_post()!{ +fn (self &${args.classname}) start_post() ! { } -fn stop_pre()!{ +fn (self &${args.classname}) stop_pre() ! { } -fn stop_post()!{ +fn (self &${args.classname}) stop_post() ! { } @@ -80,7 +78,7 @@ fn stop_post()!{ @if args.cat == .installer // checks if a certain version or above is installed -fn installed() !bool { +fn (self &${args.classname}) installed() !bool { //THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED // res := os.execute('??{osal.profile_path_source_and()!} ${args.name} version') // if res.exit_code != 0 { @@ -111,7 +109,14 @@ fn upload() ! { } -fn install() ! { + +@[params] +pub struct InstallArgs { +pub mut: + reset bool +} + +fn (mut self ${args.classname}) install(args InstallArgs) ! { console.print_header('install ${args.name}') //THIS IS EXAMPLE CODEAND NEEDS TO BE CHANGED // mut url := '' @@ -143,7 +148,7 @@ fn install() ! { } @if args.build -fn build() ! { +fn (mut self ${args.classname}) build() ! { //url := 'https://github.com/threefoldtech/${args.name}' // make sure we install base on the node @@ -174,7 +179,8 @@ fn build() ! { } @end -fn destroy() ! { +fn (mut self ${args.classname}) destroy() ! { + self.stop()! // mut systemdfactory := systemd.new()! // systemdfactory.destroy("zinit")! diff --git a/lib/core/generator/generic/templates/objname_factory_.vtemplate b/lib/core/generator/generic/templates/objname_factory_.vtemplate index f6466819..a82d5faa 100644 --- a/lib/core/generator/generic/templates/objname_factory_.vtemplate +++ b/lib/core/generator/generic/templates/objname_factory_.vtemplate @@ -171,18 +171,26 @@ pub fn play(mut plbook PlayBook) ! { for mut other_action in other_actions { if other_action.name in ["destroy","install","build"]{ mut p := other_action.params + name := p.get_default('name', 'default')! reset:=p.get_default_false("reset") + mut ${args.name}_obj:=get(name:name)! + console.print_debug("action object:\n??{${args.name}_obj}") + if other_action.name == "destroy" || reset{ console.print_debug("install action ${args.name}.destroy") - destroy()! + ${args.name}_obj.destroy()! } if other_action.name == "install"{ console.print_debug("install action ${args.name}.install") - install()! - } + ${args.name}_obj.install(reset: reset)! + } + if other_action.name == "build"{ + console.print_debug("install action ${args.name}.build") + ${args.name}_obj.build()! + } } @if args.startupmanager - if other_action.name in ["start","stop","restart"]{ + if other_action.name in ["start","stop","restart","start_pre","start_post","stop_pre","stop_post"]{ mut p := other_action.params name := p.get('name')! mut ${args.name}_obj:=get(name:name)! @@ -191,7 +199,6 @@ pub fn play(mut plbook PlayBook) ! { console.print_debug("install action ${args.name}.??{other_action.name}") ${args.name}_obj.start()! } - if other_action.name == "stop"{ console.print_debug("install action ${args.name}.??{other_action.name}") ${args.name}_obj.stop()! @@ -200,6 +207,22 @@ pub fn play(mut plbook PlayBook) ! { console.print_debug("install action ${args.name}.??{other_action.name}") ${args.name}_obj.restart()! } + if other_action.name == "start_pre"{ + console.print_debug("install action ${args.name}.??{other_action.name}") + ${args.name}_obj.start_pre()! + } + if other_action.name == "start_post"{ + console.print_debug("install action ${args.name}.??{other_action.name}") + ${args.name}_obj.start_post()! + } + if other_action.name == "stop_pre"{ + console.print_debug("install action ${args.name}.??{other_action.name}") + ${args.name}_obj.stop_pre()! + } + if other_action.name == "stop_post"{ + console.print_debug("install action ${args.name}.??{other_action.name}") + ${args.name}_obj.stop_post()! + } } @end other_action.done = true @@ -262,15 +285,13 @@ pub fn (mut self ${args.classname}) start() ! { console.print_header('installer: ${args.name} start') - if ! installed()!{ - install()! + if ! self.installed()!{ + self.install()! } - configure()! + self.start_pre()! - start_pre()! - - for zprocess in startupcmd()!{ + for zprocess in self.startupcmd()!{ mut sm:=startupmanager_get(zprocess.startuptype)! console.print_debug('installer: ${args.name} starting with ??{zprocess.startuptype}...') @@ -280,7 +301,7 @@ pub fn (mut self ${args.classname}) start() ! { sm.start(zprocess.name)! } - start_post()! + self.start_post()! for _ in 0 .. 50 { if self.running()! { @@ -300,12 +321,12 @@ pub fn (mut self ${args.classname}) install_start(args InstallArgs) ! { pub fn (mut self ${args.classname}) stop() ! { switch(self.name) - stop_pre()! - for zprocess in startupcmd()!{ + self.stop_pre()! + for zprocess in self.startupcmd()!{ mut sm:=startupmanager_get(zprocess.startuptype)! sm.stop(zprocess.name)! } - stop_post()! + self.stop_post()! } pub fn (mut self ${args.classname}) restart() ! { @@ -318,7 +339,7 @@ pub fn (mut self ${args.classname}) running() !bool { switch(self.name) //walk over the generic processes, if not running return - for zprocess in startupcmd()!{ + for zprocess in self.startupcmd()!{ if zprocess.startuptype != .screen{ mut sm:=startupmanager_get(zprocess.startuptype)! r:=sm.running(zprocess.name)! @@ -327,37 +348,10 @@ pub fn (mut self ${args.classname}) running() !bool { } } } - return running()! + return self.running_check()! } @end -@@[params] -pub struct InstallArgs{ -pub mut: - reset bool -} - -pub fn (mut self ${args.classname}) install(args InstallArgs) ! { - switch(self.name) - if args.reset || (!installed()!) { - install()! - } -} - -@if args.build -pub fn (mut self ${args.classname}) build() ! { - switch(self.name) - build()! -} -@end - -pub fn (mut self ${args.classname}) destroy() ! { - switch(self.name) -@if args.startupmanager - self.stop() or {} -@end - destroy()! -} @end From 856a6202ee4e4c2810bf9d60f5553a5c2e0c4610 Mon Sep 17 00:00:00 2001 From: Timur Gordon <31495328+timurgordon@users.noreply.github.com> Date: Wed, 19 Nov 2025 15:17:31 +0100 Subject: [PATCH 2/4] fix: escape @ symbol in template for InstallArgs annotation Use @@ instead of @ in template to properly output @[params] in generated code. V templates require double @@ to escape the @ symbol. --- lib/core/generator/generic/templates/objname_actions.vtemplate | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core/generator/generic/templates/objname_actions.vtemplate b/lib/core/generator/generic/templates/objname_actions.vtemplate index 5082315c..5ce22018 100644 --- a/lib/core/generator/generic/templates/objname_actions.vtemplate +++ b/lib/core/generator/generic/templates/objname_actions.vtemplate @@ -110,7 +110,7 @@ fn upload() ! { } -@[params] +@@[params] pub struct InstallArgs { pub mut: reset bool From a5c4b8f6f8da050b8d2ff991c70851b31ab64947 Mon Sep 17 00:00:00 2001 From: Timur Gordon <31495328+timurgordon@users.noreply.github.com> Date: Wed, 19 Nov 2025 15:44:50 +0100 Subject: [PATCH 3/4] refactor: merge action handling blocks in play() functions Merge the two separate if blocks for handling actions into a single block since they both use the same logic for getting the name parameter with get_default('name', 'default'). Changes: - Combine destroy/install/build and start/stop/restart/lifecycle blocks - All actions now use consistent name parameter handling - Reduces code duplication in play() functions Updated files: - All 5 horus installer factory files - Generator template objname_factory_.vtemplate --- .../generic/templates/objname_factory_.vtemplate | 14 ++++++-------- .../horus/coordinator/coordinator_factory_.v | 14 ++++---------- .../horus/herorunner/herorunner_factory_.v | 8 +------- .../horus/osirisrunner/osirisrunner_factory_.v | 8 +------- .../horus/salrunner/salrunner_factory_.v | 8 +------- .../horus/supervisor/supervisor_factory_.v | 9 +-------- 6 files changed, 14 insertions(+), 47 deletions(-) diff --git a/lib/core/generator/generic/templates/objname_factory_.vtemplate b/lib/core/generator/generic/templates/objname_factory_.vtemplate index a82d5faa..ac90148c 100644 --- a/lib/core/generator/generic/templates/objname_factory_.vtemplate +++ b/lib/core/generator/generic/templates/objname_factory_.vtemplate @@ -169,7 +169,11 @@ pub fn play(mut plbook PlayBook) ! { @if args.cat == .installer mut other_actions := plbook.find(filter: '${args.name}.')! for mut other_action in other_actions { + @if args.startupmanager + if other_action.name in ["destroy","install","build","start","stop","restart","start_pre","start_post","stop_pre","stop_post"]{ + @else if other_action.name in ["destroy","install","build"]{ + @end mut p := other_action.params name := p.get_default('name', 'default')! reset:=p.get_default_false("reset") @@ -188,13 +192,7 @@ pub fn play(mut plbook PlayBook) ! { console.print_debug("install action ${args.name}.build") ${args.name}_obj.build()! } - } - @if args.startupmanager - if other_action.name in ["start","stop","restart","start_pre","start_post","stop_pre","stop_post"]{ - mut p := other_action.params - name := p.get('name')! - mut ${args.name}_obj:=get(name:name)! - console.print_debug("action object:\n??{${args.name}_obj}") + @if args.startupmanager if other_action.name == "start"{ console.print_debug("install action ${args.name}.??{other_action.name}") ${args.name}_obj.start()! @@ -223,8 +221,8 @@ pub fn play(mut plbook PlayBook) ! { console.print_debug("install action ${args.name}.??{other_action.name}") ${args.name}_obj.stop_post()! } + @end } - @end other_action.done = true } @end diff --git a/lib/installers/horus/coordinator/coordinator_factory_.v b/lib/installers/horus/coordinator/coordinator_factory_.v index 367748f9..b44b3d0e 100644 --- a/lib/installers/horus/coordinator/coordinator_factory_.v +++ b/lib/installers/horus/coordinator/coordinator_factory_.v @@ -38,13 +38,13 @@ pub fn new(args ArgsGet) !&Coordinator { log_level: args.log_level repo_path: args.repo_path } - + // Try to set in Redis, if it fails (Redis not available), use in-memory config set(obj) or { console.print_debug('Redis not available, using in-memory configuration') set_in_mem(obj)! } - + return get(name: args.name)! } @@ -154,13 +154,13 @@ pub fn play(mut plbook PlayBook) ! { } mut other_actions := plbook.find(filter: 'coordinator.')! for mut other_action in other_actions { - if other_action.name in ['destroy', 'install', 'build'] { + if other_action.name in ['destroy', 'install', 'build', 'start', 'stop', 'restart', 'start_pre', 'start_post', 'stop_pre', 'stop_post'] { mut p := other_action.params name := p.get_default('name', 'default')! reset := p.get_default_false('reset') mut coordinator_obj := get(name: name)! console.print_debug('action object:\n${coordinator_obj}') - + if other_action.name == 'destroy' || reset { console.print_debug('install action coordinator.destroy') coordinator_obj.destroy()! @@ -173,12 +173,6 @@ pub fn play(mut plbook PlayBook) ! { console.print_debug('install action coordinator.build') coordinator_obj.build()! } - } - if other_action.name in ['start', 'stop', 'restart', 'start_pre', 'start_post', 'stop_pre', 'stop_post'] { - mut p := other_action.params - name := p.get('name')! - mut coordinator_obj := get(name: name)! - console.print_debug('action object:\n${coordinator_obj}') if other_action.name == 'start' { console.print_debug('install action coordinator.${other_action.name}') coordinator_obj.start()! diff --git a/lib/installers/horus/herorunner/herorunner_factory_.v b/lib/installers/horus/herorunner/herorunner_factory_.v index 27f7d13b..b681c0b2 100644 --- a/lib/installers/horus/herorunner/herorunner_factory_.v +++ b/lib/installers/horus/herorunner/herorunner_factory_.v @@ -142,7 +142,7 @@ pub fn play(mut plbook PlayBook) ! { } mut other_actions := plbook.find(filter: 'herorunner.')! for mut other_action in other_actions { - if other_action.name in ['destroy', 'install', 'build'] { + if other_action.name in ['destroy', 'install', 'build', 'start', 'stop', 'restart', 'start_pre', 'start_post', 'stop_pre', 'stop_post'] { mut p := other_action.params name := p.get_default('name', 'default')! reset := p.get_default_false('reset') @@ -161,12 +161,6 @@ pub fn play(mut plbook PlayBook) ! { console.print_debug('install action herorunner.build') herorunner_obj.build()! } - } - if other_action.name in ['start', 'stop', 'restart', 'start_pre', 'start_post', 'stop_pre', 'stop_post'] { - mut p := other_action.params - name := p.get('name')! - mut herorunner_obj := get(name: name)! - console.print_debug('action object:\n${herorunner_obj}') if other_action.name == 'start' { console.print_debug('install action herorunner.${other_action.name}') herorunner_obj.start()! diff --git a/lib/installers/horus/osirisrunner/osirisrunner_factory_.v b/lib/installers/horus/osirisrunner/osirisrunner_factory_.v index 0ff3673b..9a0ee0ab 100644 --- a/lib/installers/horus/osirisrunner/osirisrunner_factory_.v +++ b/lib/installers/horus/osirisrunner/osirisrunner_factory_.v @@ -144,7 +144,7 @@ pub fn play(mut plbook PlayBook) ! { } mut other_actions := plbook.find(filter: 'osirisrunner.')! for mut other_action in other_actions { - if other_action.name in ['destroy', 'install', 'build'] { + if other_action.name in ['destroy', 'install', 'build', 'start', 'stop', 'restart', 'start_pre', 'start_post', 'stop_pre', 'stop_post'] { mut p := other_action.params name := p.get_default('name', 'default')! reset := p.get_default_false('reset') @@ -163,12 +163,6 @@ pub fn play(mut plbook PlayBook) ! { console.print_debug('install action osirisrunner.build') osirisrunner_obj.build()! } - } - if other_action.name in ['start', 'stop', 'restart', 'start_pre', 'start_post', 'stop_pre', 'stop_post'] { - mut p := other_action.params - name := p.get('name')! - mut osirisrunner_obj := get(name: name)! - console.print_debug('action object:\n${osirisrunner_obj}') if other_action.name == 'start' { console.print_debug('install action osirisrunner.${other_action.name}') osirisrunner_obj.start()! diff --git a/lib/installers/horus/salrunner/salrunner_factory_.v b/lib/installers/horus/salrunner/salrunner_factory_.v index 169c3452..4be86568 100644 --- a/lib/installers/horus/salrunner/salrunner_factory_.v +++ b/lib/installers/horus/salrunner/salrunner_factory_.v @@ -144,7 +144,7 @@ pub fn play(mut plbook PlayBook) ! { } mut other_actions := plbook.find(filter: 'salrunner.')! for mut other_action in other_actions { - if other_action.name in ['destroy', 'install', 'build'] { + if other_action.name in ['destroy', 'install', 'build', 'start', 'stop', 'restart', 'start_pre', 'start_post', 'stop_pre', 'stop_post'] { mut p := other_action.params name := p.get_default('name', 'default')! reset := p.get_default_false('reset') @@ -163,12 +163,6 @@ pub fn play(mut plbook PlayBook) ! { console.print_debug('install action salrunner.build') salrunner_obj.build()! } - } - if other_action.name in ['start', 'stop', 'restart', 'start_pre', 'start_post', 'stop_pre', 'stop_post'] { - mut p := other_action.params - name := p.get('name')! - mut salrunner_obj := get(name: name)! - console.print_debug('action object:\n${salrunner_obj}') if other_action.name == 'start' { console.print_debug('install action salrunner.${other_action.name}') salrunner_obj.start()! diff --git a/lib/installers/horus/supervisor/supervisor_factory_.v b/lib/installers/horus/supervisor/supervisor_factory_.v index cd5ef0be..d4fc62a4 100644 --- a/lib/installers/horus/supervisor/supervisor_factory_.v +++ b/lib/installers/horus/supervisor/supervisor_factory_.v @@ -148,7 +148,7 @@ pub fn play(mut plbook PlayBook) ! { } mut other_actions := plbook.find(filter: 'supervisor.')! for mut other_action in other_actions { - if other_action.name in ['destroy', 'install', 'build'] { + if other_action.name in ['destroy', 'install', 'build', 'start', 'stop', 'restart', 'start_pre', 'start_post', 'stop_pre', 'stop_post'] { mut p := other_action.params name := p.get_default('name', 'default')! reset := p.get_default_false('reset') @@ -167,12 +167,6 @@ pub fn play(mut plbook PlayBook) ! { console.print_debug('install action supervisor.build') supervisor_obj.build()! } - } - if other_action.name in ['start', 'stop', 'restart', 'start_pre', 'start_post', 'stop_pre', 'stop_post'] { - mut p := other_action.params - name := p.get('name')! - mut supervisor_obj := get(name: name)! - console.print_debug('action object:\n${supervisor_obj}') if other_action.name == 'start' { console.print_debug('install action supervisor.${other_action.name}') supervisor_obj.start()! @@ -319,7 +313,6 @@ pub fn (mut self Supervisor) running() !bool { return self.running_check()! } - // switch instance to be used for supervisor pub fn switch(name string) { supervisor_default = name From 86da2cd435dceef9bc21cc34a6ac3d6865f1e92e Mon Sep 17 00:00:00 2001 From: Timur Gordon <31495328+timurgordon@users.noreply.github.com> Date: Wed, 19 Nov 2025 15:51:20 +0100 Subject: [PATCH 4/4] 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 --- .../templates/objname_actions.vtemplate | 2 +- lib/installers/base/redis/redis_actions.v | 28 ++++----- .../horus/coordinator/coordinator_actions.v | 57 +++++++++-------- .../horus/coordinator/coordinator_model.v | 16 ++--- .../horus/herorunner/herorunner_actions.v | 27 ++++---- .../horus/herorunner/herorunner_model.v | 8 +-- .../horus/osirisrunner/osirisrunner_actions.v | 27 ++++---- .../horus/osirisrunner/osirisrunner_model.v | 10 +-- .../horus/salrunner/salrunner_actions.v | 27 ++++---- .../horus/salrunner/salrunner_model.v | 10 +-- .../horus/supervisor/supervisor_actions.v | 61 ++++++++++--------- .../horus/supervisor/supervisor_model.v | 14 ++--- 12 files changed, 145 insertions(+), 142 deletions(-) diff --git a/lib/core/generator/generic/templates/objname_actions.vtemplate b/lib/core/generator/generic/templates/objname_actions.vtemplate index 5ce22018..caae17e3 100644 --- a/lib/core/generator/generic/templates/objname_actions.vtemplate +++ b/lib/core/generator/generic/templates/objname_actions.vtemplate @@ -110,7 +110,7 @@ fn upload() ! { } -@@[params] +^^[params] pub struct InstallArgs { pub mut: reset bool diff --git a/lib/installers/base/redis/redis_actions.v b/lib/installers/base/redis/redis_actions.v index b1b9d513..272c7cb0 100644 --- a/lib/installers/base/redis/redis_actions.v +++ b/lib/installers/base/redis/redis_actions.v @@ -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}') } diff --git a/lib/installers/horus/coordinator/coordinator_actions.v b/lib/installers/horus/coordinator/coordinator_actions.v index 61d37e75..f279441f 100644 --- a/lib/installers/horus/coordinator/coordinator_actions.v +++ b/lib/installers/horus/coordinator/coordinator_actions.v @@ -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)! } diff --git a/lib/installers/horus/coordinator/coordinator_model.v b/lib/installers/horus/coordinator/coordinator_model.v index 6d24d6bf..48458f12 100644 --- a/lib/installers/horus/coordinator/coordinator_model.v +++ b/lib/installers/horus/coordinator/coordinator_model.v @@ -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' diff --git a/lib/installers/horus/herorunner/herorunner_actions.v b/lib/installers/horus/herorunner/herorunner_actions.v index 38f43a96..721b681d 100644 --- a/lib/installers/horus/herorunner/herorunner_actions.v +++ b/lib/installers/horus/herorunner/herorunner_actions.v @@ -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)! } diff --git a/lib/installers/horus/herorunner/herorunner_model.v b/lib/installers/horus/herorunner/herorunner_model.v index c6a53b9f..7dd9dce4 100644 --- a/lib/installers/horus/herorunner/herorunner_model.v +++ b/lib/installers/horus/herorunner/herorunner_model.v @@ -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 diff --git a/lib/installers/horus/osirisrunner/osirisrunner_actions.v b/lib/installers/horus/osirisrunner/osirisrunner_actions.v index 0eff803b..d2126329 100644 --- a/lib/installers/horus/osirisrunner/osirisrunner_actions.v +++ b/lib/installers/horus/osirisrunner/osirisrunner_actions.v @@ -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)! } diff --git a/lib/installers/horus/osirisrunner/osirisrunner_model.v b/lib/installers/horus/osirisrunner/osirisrunner_model.v index 6a7ee52d..639e3e76 100644 --- a/lib/installers/horus/osirisrunner/osirisrunner_model.v +++ b/lib/installers/horus/osirisrunner/osirisrunner_model.v @@ -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 diff --git a/lib/installers/horus/salrunner/salrunner_actions.v b/lib/installers/horus/salrunner/salrunner_actions.v index 6ed141e8..03b32588 100644 --- a/lib/installers/horus/salrunner/salrunner_actions.v +++ b/lib/installers/horus/salrunner/salrunner_actions.v @@ -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)! } diff --git a/lib/installers/horus/salrunner/salrunner_model.v b/lib/installers/horus/salrunner/salrunner_model.v index f1d8da9e..4e40ca1f 100644 --- a/lib/installers/horus/salrunner/salrunner_model.v +++ b/lib/installers/horus/salrunner/salrunner_model.v @@ -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 diff --git a/lib/installers/horus/supervisor/supervisor_actions.v b/lib/installers/horus/supervisor/supervisor_actions.v index 59e6ade5..fc42f0f7 100644 --- a/lib/installers/horus/supervisor/supervisor_actions.v +++ b/lib/installers/horus/supervisor/supervisor_actions.v @@ -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)! } diff --git a/lib/installers/horus/supervisor/supervisor_model.v b/lib/installers/horus/supervisor/supervisor_model.v index fae24e1e..636e94ee 100644 --- a/lib/installers/horus/supervisor/supervisor_model.v +++ b/lib/installers/horus/supervisor/supervisor_model.v @@ -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