diff --git a/configurations/beelzebub.yaml b/configurations/beelzebub.yaml index e2f56b3..5b2fe43 100644 --- a/configurations/beelzebub.yaml +++ b/configurations/beelzebub.yaml @@ -5,5 +5,5 @@ core: logDisableTimestamp: true logsPath: ./logs tracing: - rabbitMQEnabled: true + rabbitMQEnabled: false rabbitMQURI: "" diff --git a/docker-compose.yml b/docker-compose.yml index 1b7c4fe..a5e930c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ services: #network_mode: host # Not work on Mac OS container_name: beelzebub restart: always - ports: # Remove me, if use configuration network_mode: host + ports: # Remove me, if you use configuration network_mode: host - "22:22" - "8080:8080" - "80:80" @@ -15,14 +15,4 @@ services: depends_on: - rabbitmq volumes: - - "./configurations:/configurations" - - rabbitmq: - image: rabbitmq:3-management-alpine - container_name: 'rabbitmq' - ports: - - "5672:5672" - - "15672:15672" - environment: - RABBITMQ_DEFAULT_USER: ${RABBITMQ_DEFAULT_USER} - RABBITMQ_DEFAULT_PASS: ${RABBITMQ_DEFAULT_PASS} \ No newline at end of file + - "./configurations:/configurations" \ No newline at end of file diff --git a/main.go b/main.go index 7ac0ac5..3e6bb5b 100644 --- a/main.go +++ b/main.go @@ -20,7 +20,7 @@ func main() { parser := parser.Init("./configurations/beelzebub.yaml", "./configurations/services/") coreConfigurations, err := parser.ReadConfigurationsCore() - failOnError(err, fmt.Sprintf("Error during coreConfigurations: ")) + failOnError(err, fmt.Sprintf("Error during ReadConfigurationsCore: ")) fileLogs := configureLoggingByConfigurations(coreConfigurations.Core.Logging) defer fileLogs.Close() @@ -33,13 +33,9 @@ func main() { if !configured { rabbitMQURI = coreConfigurations.Core.Tracing.RabbitMQURI } - conn, err := amqp.Dial(rabbitMQURI) - failOnError(err, "Failed to connect to RabbitMQ") - defer conn.Close() - - channel, err = conn.Channel() - failOnError(err, "Failed to open a channel") + conn, channel := buildRabbitMQ(rabbitMQURI) defer channel.Close() + defer conn.Close() } // Init Protocol strategies @@ -126,3 +122,13 @@ func configureLoggingByConfigurations(configurations parser.Logging) *os.File { } return file } + +func buildRabbitMQ(rabbitMQURI string) (*amqp.Connection, *amqp.Channel) { + conn, err := amqp.Dial(rabbitMQURI) + failOnError(err, "Failed to init Dial rabbitMQ") + + channel, err := conn.Channel() + failOnError(err, "Failed to connect on Channel") + + return conn, channel +}