Moge-Row commited on
Commit
5107e71
1 Parent(s): 3dc62e0

force: rebuilding server with recovery mode

Browse files
Files changed (1) hide show
  1. main.go +29 -15
main.go CHANGED
@@ -1,21 +1,35 @@
1
  package main
 
2
  import (
3
- "log"
4
- "net/http"
5
- "os"
6
  )
 
7
  func main() {
8
- // Servir la interfaz visual
9
- http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
10
- http.ServeFile(w, r, "index.html")
11
- })
 
 
 
 
 
 
 
 
 
 
 
12
 
13
- // IMPORTANTE: Aqu铆 es donde el servidor activa las funciones de tus otros archivos
14
- // Si tu funci贸n de inicio en keys.go o index.go tiene otro nombre, c谩mbialo aqu铆.
15
- SetupRoutes()
16
 
17
- port := os.Getenv("PORT")
18
- if port == "" { port = "7860" }
19
- log.Printf("Servidor reiniciado en puerto %s", port)
20
- log.Fatal(http.ListenAndServe(":" + port, nil))
21
- }
 
 
1
  package main
2
+
3
  import (
4
+ "log"
5
+ "net/http"
6
+ "os"
7
  )
8
+
9
  func main() {
10
+ // 1. Servir la interfaz visual (HOI4)
11
+ http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
12
+ http.ServeFile(w, r, "index.html")
13
+ })
14
+
15
+ // 2. Intentar registrar las rutas del proxy (v1, stats, etc)
16
+ // Usamos un recovery para que si falla, el servidor no muera
17
+ defer func() {
18
+ if r := recover(); r != nil {
19
+ log.Printf("Error recuperado: %v", r)
20
+ }
21
+ }()
22
+
23
+ // Llama a la l贸gica de tus otros archivos
24
+ InitRoutes()
25
 
26
+ // 3. Configuraci贸n del puerto
27
+ port := os.Getenv("PORT")
28
+ if port == "" { port = "7860" }
29
 
30
+ log.Printf("Servidor operativo en puerto %s", port)
31
+ err := http.ListenAndServe(":" + port, nil)
32
+ if err != nil {
33
+ log.Fatal(err)
34
+ }
35
+ }