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!')
|
||||
|
||||
Reference in New Issue
Block a user