-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
36 lines (27 loc) · 884 Bytes
/
Copy pathmain.go
File metadata and controls
36 lines (27 loc) · 884 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
import (
"log"
"net/http"
"sync"
routes "code-processor/http"
"code-processor/rabbitmq"
"code-processor/storage"
)
func main() {
storage.InitStorage()
// Запуск RabbitMQ consumer в отдельной горутине
var wg sync.WaitGroup
wg.Add(1)
go func() {
defer wg.Done()
rabbitmq.StartConsumer(storage.StorageInstance.TaskRepository) // Передаем taskRepo в качестве TaskUpdater
}()
log.Println("Waiting for consumer to start...")
// Запускаем HTTP-сервер с созданием маршрутов и передачей репозиториев
r := routes.NewRouter()
r.Handle("/metrics", routes.PrometheusHandler())
log.Println("Starting server on :8000")
log.Fatal(http.ListenAndServe(":8000", r))
// Ждем завершения потребителя перед выходом
wg.Wait()
}