-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
41 lines (35 loc) · 967 Bytes
/
Copy pathmain.go
File metadata and controls
41 lines (35 loc) · 967 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
37
38
39
40
41
package main
import (
"log"
"net/http"
"os"
"strconv"
"searxgo/internal/config"
"searxgo/internal/server"
)
func main() {
// Load configuration from TOML file
cfg, err := config.LoadConfig("config.toml")
if err != nil {
log.Fatalf("Failed to load configuration: %v", err)
}
// Load enabled engines based on configuration
engs := cfg.LoadEnabledEngines()
if len(engs) == 0 {
log.Fatal("No search engines enabled in configuration")
}
srv := server.NewServer(engs)
srv.Timeout = cfg.GetTimeout()
srv.StaticDir = cfg.Server.StaticDir
srv.DefaultSize = cfg.Server.DefaultSize
handler := srv.Handler()
port := cfg.Server.Port
addr := ":" + strconv.Itoa(port)
if v := os.Getenv("PORT"); v != "" {
addr = ":" + v
}
log.Printf("listening on %s", addr)
if err := http.ListenAndServe(addr, handler); err != nil {
log.Fatal(err)
}
}