mchess-server/main.go

41 lines
672 B
Go
Raw Normal View History

2022-10-22 18:01:55 +00:00
package main
import (
2022-11-19 10:41:10 +00:00
"log"
2022-11-19 12:25:00 +00:00
"mchess_server/server"
2022-11-19 10:41:10 +00:00
"net/http"
2022-12-18 14:43:27 +00:00
"os"
2022-10-22 18:01:55 +00:00
)
var cert_path = "/etc/letsencrypt/live/chess.sw-gross.de/"
var cert_file = cert_path + "fullchain.pem"
var key_file = cert_path + "privkey.pem"
2022-10-22 18:01:55 +00:00
func main() {
2022-12-18 14:43:27 +00:00
hostname, err := os.Hostname()
if err != nil {
log.Println(err)
}
2022-11-19 10:41:10 +00:00
http.HandleFunc("/", server.SocketHandler)
if hostname == "mbook" { // My test environment
err = http.ListenAndServe(":8080", nil)
if err != nil {
log.Println(err)
}
} else {
err = http.ListenAndServeTLS(":8080", cert_file, key_file, nil)
if err != nil {
log.Println(err)
}
2022-11-19 10:41:10 +00:00
}
log.Println("Fin")
2022-10-22 18:01:55 +00:00
}
func HandleFuncWrapper(a func()) {
a()
}