mirror of
https://github.com/DeBrosOfficial/network.git
synced 2025-12-12 22:58:49 +00:00
feat: enhance service management and configuration options
- Updated service startup logic to include a helper function for starting or restarting services, improving reliability and clarity in service management. - Added new configuration options for cluster synchronization, peer inactivity limits, and minimum cluster size in the config_commands.go file, enhancing cluster management capabilities.
This commit is contained in:
parent
ebe2706ad8
commit
c326711d7c
@ -422,6 +422,9 @@ database:
|
||||
rqlite_port: %d
|
||||
rqlite_raft_port: %d
|
||||
rqlite_join_address: "%s"
|
||||
cluster_sync_interval: "30s"
|
||||
peer_inactivity_limit: "24h"
|
||||
min_cluster_size: 1
|
||||
|
||||
discovery:
|
||||
%s
|
||||
@ -466,6 +469,9 @@ database:
|
||||
rqlite_port: %d
|
||||
rqlite_raft_port: %d
|
||||
rqlite_join_address: ""
|
||||
cluster_sync_interval: "30s"
|
||||
peer_inactivity_limit: "24h"
|
||||
min_cluster_size: 1
|
||||
|
||||
discovery:
|
||||
bootstrap_peers: []
|
||||
|
||||
@ -960,19 +960,46 @@ WantedBy=multi-user.target
|
||||
}
|
||||
|
||||
func startServices() {
|
||||
fmt.Printf("🚀 Starting services...\n")
|
||||
fmt.Printf("🚀 Starting/Restarting services...\n")
|
||||
|
||||
// Start node
|
||||
if err := exec.Command("systemctl", "start", "debros-node").Run(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "⚠️ Failed to start node service: %v\n", err)
|
||||
} else {
|
||||
fmt.Printf(" ✓ Node service started\n")
|
||||
// Helper function to start or restart a service
|
||||
startOrRestartService := func(serviceName string) {
|
||||
// Check if service is active/running
|
||||
checkCmd := exec.Command("systemctl", "is-active", "--quiet", serviceName)
|
||||
isRunning := checkCmd.Run() == nil
|
||||
|
||||
if isRunning {
|
||||
// Service is running, restart it
|
||||
fmt.Printf(" Restarting %s service...\n", serviceName)
|
||||
if err := exec.Command("systemctl", "restart", serviceName).Run(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "⚠️ Failed to restart %s service: %v\n", serviceName, err)
|
||||
} else {
|
||||
fmt.Printf(" ✓ %s service restarted\n", serviceName)
|
||||
}
|
||||
} else {
|
||||
// Service is not running, start it
|
||||
fmt.Printf(" Starting %s service...\n", serviceName)
|
||||
if err := exec.Command("systemctl", "start", serviceName).Run(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "⚠️ Failed to start %s service: %v\n", serviceName, err)
|
||||
} else {
|
||||
fmt.Printf(" ✓ %s service started\n", serviceName)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Start gateway
|
||||
if err := exec.Command("systemctl", "start", "debros-gateway").Run(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "⚠️ Failed to start gateway service: %v\n", err)
|
||||
} else {
|
||||
fmt.Printf(" ✓ Gateway service started\n")
|
||||
// Start or restart node service
|
||||
startOrRestartService("debros-node")
|
||||
|
||||
// Start or restart gateway service
|
||||
startOrRestartService("debros-gateway")
|
||||
|
||||
// Also restart Anon service if it's running (to pick up any config changes)
|
||||
if exec.Command("systemctl", "is-active", "--quiet", "anon").Run() == nil {
|
||||
fmt.Printf(" Restarting Anon service to pick up config changes...\n")
|
||||
if err := exec.Command("systemctl", "restart", "anon").Run(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "⚠️ Failed to restart Anon service: %v\n", err)
|
||||
} else {
|
||||
fmt.Printf(" ✓ Anon service restarted\n")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user