Spaces:
Paused
Paused
force: rebuilding server with recovery mode
Browse files
main.go
CHANGED
|
@@ -1,21 +1,35 @@
|
|
| 1 |
package main
|
|
|
|
| 2 |
import (
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
)
|
|
|
|
| 7 |
func main() {
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 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 |
+
}
|