diff --git a/examples/installers/horus/coordinator b/examples/installers/horus/coordinator deleted file mode 100755 index 49e9b260..00000000 Binary files a/examples/installers/horus/coordinator and /dev/null differ diff --git a/lib/installers/horus/coordinator/coordinator_actions.v b/lib/installers/horus/coordinator/coordinator_actions.v index 4e0bf79c..6040ff97 100644 --- a/lib/installers/horus/coordinator/coordinator_actions.v +++ b/lib/installers/horus/coordinator/coordinator_actions.v @@ -8,6 +8,7 @@ import incubaid.herolib.installers.ulist import incubaid.herolib.installers.lang.rust import incubaid.herolib.installers.base.redis import incubaid.herolib.develop.gittools +import os fn startupcmd() ![]startupmanager.ZProcessNewArgs { mut cfg := get()! @@ -17,6 +18,7 @@ fn startupcmd() ![]startupmanager.ZProcessNewArgs { name: 'coordinator' cmd: '${cfg.binary_path} --redis-addr ${cfg.redis_addr} --api-http-port ${cfg.http_port} --api-ws-port ${cfg.ws_port}' env: { + 'HOME': os.home_dir() 'RUST_LOG': cfg.log_level 'RUST_LOG_STYLE': 'never' } @@ -79,18 +81,26 @@ fn upload() ! { } // Helper function to ensure Redis is installed and running -fn ensure_redis_running() ! { +@[params] +struct EnsureRedisArgs { +pub mut: + redis_port int = 6379 + redis_addr string = 'localhost' + datadir string = '/var/lib/redis' +} + +fn ensure_redis_running(args EnsureRedisArgs) ! { redis_config := redis.RedisInstall{ - port: 6379 - datadir: '/var/lib/redis' - ipaddr: 'localhost' + port: args.redis_port + datadir: args.datadir + ipaddr: args.redis_addr } if !redis.check(redis_config) { - println('Installing and starting Redis...') + println('Installing and starting Redis on ${args.redis_addr}:${args.redis_port}...') redis.redis_install(redis_config)! } else { - println('Redis is already running') + println('Redis is already running on ${args.redis_addr}:${args.redis_port}') } } @@ -122,7 +132,10 @@ pub fn build() ! { // Ensure Redis is installed and running (required for coordinator) println('Step 1/4: Checking Redis dependency...') - ensure_redis_running()! + // Parse redis_addr to extract host + parts := cfg.redis_addr.split(':') + redis_host := if parts.len > 0 { parts[0] } else { 'localhost' } + ensure_redis_running(redis_port: cfg.redis_port, redis_addr: redis_host)! println('Redis is ready\n') // Ensure rust is installed diff --git a/lib/installers/horus/coordinator/coordinator_model.v b/lib/installers/horus/coordinator/coordinator_model.v index 26fcdd62..453298bf 100644 --- a/lib/installers/horus/coordinator/coordinator_model.v +++ b/lib/installers/horus/coordinator/coordinator_model.v @@ -15,6 +15,7 @@ pub mut: name string = 'default' binary_path string = '/hero/var/bin/coordinator' redis_addr string = '127.0.0.1:6379' + redis_port int = 6379 http_port int = 8081 ws_port int = 9653 log_level string = 'info' @@ -36,6 +37,9 @@ fn obj_init(mycfg_ CoordinatorServer) !CoordinatorServer { if mycfg.redis_addr == '' { mycfg.redis_addr = '127.0.0.1:6379' } + if mycfg.redis_port == 0 { + mycfg.redis_port = 6379 + } if mycfg.http_port == 0 { mycfg.http_port = 8081 }