refactor: move coordinator installer to horus directory and fix Redis installer permissions
- Moved coordinator installer from installers/infra to installers/horus - Renamed HerocoordinatorServer to CoordinatorServer - Fixed Redis installer permissions for /var/lib/redis directory - Integrated coordinator with new modular Redis installer
This commit is contained in:
@@ -1,39 +1,46 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import incubaid.herolib.installers.base
|
||||
import incubaid.herolib.osal.core as osal
|
||||
import time
|
||||
import incubaid.herolib.installers.base.redis
|
||||
|
||||
println('=== Redis Installer Example ===\n')
|
||||
|
||||
// Check if redis is already installed
|
||||
if osal.cmd_exists_profile('redis-server') {
|
||||
println('✅ redis-server is already installed')
|
||||
|
||||
// Check if it's running
|
||||
if base.check(port: 6379) {
|
||||
println('✅ Redis is running and responding')
|
||||
} else {
|
||||
println('⚠️ Redis is installed but not running, starting it...')
|
||||
// Use systemctl to start redis
|
||||
osal.exec(cmd: 'systemctl start redis-server')!
|
||||
|
||||
// Wait a moment for redis to start
|
||||
time.sleep(1000)
|
||||
|
||||
if base.check(port: 6379) {
|
||||
println('✅ Redis started successfully')
|
||||
} else {
|
||||
println('❌ Failed to start redis')
|
||||
}
|
||||
}
|
||||
} else {
|
||||
println('Redis not found, installing...')
|
||||
|
||||
// Install and start redis
|
||||
base.redis_install(port: 6379, start: true)!
|
||||
|
||||
println('✅ Redis installed and started successfully')
|
||||
// Create configuration
|
||||
// You can customize port, datadir, and ipaddr as needed
|
||||
config := redis.RedisInstall{
|
||||
port: 6379 // Redis port
|
||||
datadir: '/var/lib/redis' // Data directory (standard location)
|
||||
ipaddr: 'localhost' // Bind address
|
||||
}
|
||||
|
||||
println('\n✅ Done!')
|
||||
// Check if Redis is already running
|
||||
if redis.check(config) {
|
||||
println('INFO: Redis is already running on port ${config.port}')
|
||||
println(' To reinstall, stop Redis first: redis.stop()!')
|
||||
} else {
|
||||
// Install and start Redis
|
||||
println('Installing and starting Redis...')
|
||||
println(' Port: ${config.port}')
|
||||
println(' Data directory: ${config.datadir}')
|
||||
println(' Bind address: ${config.ipaddr}\n')
|
||||
|
||||
redis.redis_install(config)!
|
||||
|
||||
// Verify installation
|
||||
if redis.check(config) {
|
||||
println('\nSUCCESS: Redis installed and started successfully!')
|
||||
println(' You can now connect to Redis on port ${config.port}')
|
||||
println(' Test with: redis-cli ping')
|
||||
} else {
|
||||
println('\nERROR: Redis installation completed but failed to start')
|
||||
println(' Check logs: journalctl -u redis-server -n 20')
|
||||
}
|
||||
}
|
||||
|
||||
println('\n=== Available Functions ===')
|
||||
println(' redis.redis_install(config)! - Install and start Redis')
|
||||
println(' redis.start(config)! - Start Redis')
|
||||
println(' redis.stop()! - Stop Redis')
|
||||
println(' redis.restart(config)! - Restart Redis')
|
||||
println(' redis.check(config) - Check if running')
|
||||
|
||||
println('\nDone!')
|
||||
|
||||
BIN
examples/installers/horus/coordinator
Executable file
BIN
examples/installers/horus/coordinator
Executable file
Binary file not shown.
31
examples/installers/horus/coordinator.vsh
Executable file
31
examples/installers/horus/coordinator.vsh
Executable file
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import incubaid.herolib.installers.horus.coordinator
|
||||
|
||||
// Example usage of coordinator installer
|
||||
// This will:
|
||||
// 1. Check and install Redis if not running (required dependency)
|
||||
// 2. Install Rust if not already installed
|
||||
// 3. Clone the horus repository
|
||||
// 4. Build the coordinator binary
|
||||
|
||||
println('Building coordinator from horus repository...')
|
||||
println('(This will install Redis and Rust if not already installed)\n')
|
||||
|
||||
// Create coordinator instance - will auto-install Redis if needed
|
||||
mut coord := coordinator.new()!
|
||||
|
||||
// Build and install
|
||||
coord.install()!
|
||||
|
||||
println('\nCoordinator built and installed successfully!')
|
||||
println('Binary location: ${coord.binary_path}')
|
||||
|
||||
// Note: To start the service, uncomment the lines below
|
||||
// (requires proper zinit or screen session setup)
|
||||
// coord.start()!
|
||||
// if coord.running()! {
|
||||
// println('Coordinator is running!')
|
||||
// }
|
||||
// coord.stop()!
|
||||
// coord.destroy()!
|
||||
@@ -1,30 +0,0 @@
|
||||
#!/usr/bin/env -S v -n -w -gc none -cc tcc -d use_openssl -enable-globals run
|
||||
|
||||
import incubaid.herolib.installers.infra.herocoordinator
|
||||
|
||||
// Example usage of herocoordinator installer
|
||||
// This will:
|
||||
// 1. Check and install Redis if not running (required dependency)
|
||||
// 2. Install Rust if not already installed
|
||||
// 3. Clone the horus repository
|
||||
// 4. Build the herocoordinator binary
|
||||
|
||||
// Build and install herocoordinator
|
||||
// This will automatically check and install Redis and Rust if needed
|
||||
println('Building coordinator from horus repository...')
|
||||
println('(This will install Redis and Rust if not already installed)\n')
|
||||
|
||||
// Call build_coordinator - it will handle all dependencies
|
||||
herocoordinator.build_coordinator()!
|
||||
|
||||
println('\n✅ Herocoordinator built and installed successfully!')
|
||||
println('Binary location: /hero/var/bin/coordinator')
|
||||
|
||||
// Note: To start the service, uncomment the lines below
|
||||
// (requires proper zinit or screen session setup)
|
||||
// herocoordinator.start()!
|
||||
// if herocoordinator.running()! {
|
||||
// println('Herocoordinator is running!')
|
||||
// }
|
||||
// herocoordinator.stop()!
|
||||
// herocoordinator.destroy()!
|
||||
Reference in New Issue
Block a user