mirror of
https://github.com/gusaul/grpcox.git
synced 2024-12-25 09:50:10 +00:00
38 lines
705 B
Go
38 lines
705 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"log"
|
|
"net/http"
|
|
"os"
|
|
"time"
|
|
|
|
"github.com/gorilla/mux"
|
|
"github.com/gusaul/grpcox/handler"
|
|
)
|
|
|
|
func main() {
|
|
// logging conf
|
|
f, err := os.OpenFile("log/grpcox.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
|
|
if err != nil {
|
|
log.Fatalf("error opening file: %v", err)
|
|
}
|
|
defer f.Close()
|
|
log.SetOutput(f)
|
|
log.SetFlags(log.LstdFlags | log.Lshortfile)
|
|
|
|
// start app
|
|
port := ":6969"
|
|
muxRouter := mux.NewRouter()
|
|
handler.Init(muxRouter)
|
|
srv := &http.Server{
|
|
Handler: muxRouter,
|
|
Addr: "0.0.0.0" + port,
|
|
WriteTimeout: 15 * time.Second,
|
|
ReadTimeout: 15 * time.Second,
|
|
}
|
|
|
|
fmt.Println("Service started on", port)
|
|
log.Fatal(srv.ListenAndServe())
|
|
}
|