feat: add configuration management and update deployment files
This commit is contained in:
16
main.go
16
main.go
@@ -1,9 +1,13 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"k8s-example/cmn/conf"
|
||||
"k8s-example/hello"
|
||||
"net/http"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -11,10 +15,18 @@ var (
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
// read -f parameter (config file)
|
||||
configPath := flag.String("f", ".linux-config.json", "config file")
|
||||
flag.Parse()
|
||||
conf.Init(*configPath)
|
||||
|
||||
http.HandleFunc("/hello", hello.Handler)
|
||||
|
||||
fmt.Println("server on :8800, version:", version)
|
||||
err := http.ListenAndServe(":8800", nil)
|
||||
port := viper.GetInt("server.port")
|
||||
|
||||
fmt.Println("server on :", port, "version:", version)
|
||||
err := http.ListenAndServe(fmt.Sprintf(":%d", port), nil)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user