|
@@ -4,11 +4,9 @@ import (
|
|
|
"crypto/tls"
|
|
"crypto/tls"
|
|
|
"fmt"
|
|
"fmt"
|
|
|
"log"
|
|
"log"
|
|
|
- "math/rand"
|
|
|
|
|
"net"
|
|
"net"
|
|
|
"net/http"
|
|
"net/http"
|
|
|
"os"
|
|
"os"
|
|
|
- "time"
|
|
|
|
|
|
|
|
|
|
"github.com/coreos/etcd/config"
|
|
"github.com/coreos/etcd/config"
|
|
|
"github.com/coreos/etcd/etcd"
|
|
"github.com/coreos/etcd/etcd"
|
|
@@ -28,7 +26,7 @@ func main() {
|
|
|
os.Exit(0)
|
|
os.Exit(0)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- e := etcd.New(config, genId())
|
|
|
|
|
|
|
+ e := etcd.New(config)
|
|
|
go e.Run()
|
|
go e.Run()
|
|
|
|
|
|
|
|
corsInfo, err := ehttp.NewCORSInfo(config.CorsOrigins)
|
|
corsInfo, err := ehttp.NewCORSInfo(config.CorsOrigins)
|
|
@@ -42,11 +40,6 @@ func main() {
|
|
|
serve("etcd", config.BindAddr, config.EtcdTLSInfo(), corsInfo, e)
|
|
serve("etcd", config.BindAddr, config.EtcdTLSInfo(), corsInfo, e)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-func genId() int64 {
|
|
|
|
|
- r := rand.New(rand.NewSource(int64(time.Now().Nanosecond())))
|
|
|
|
|
- return r.Int63()
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
func serve(who string, addr string, tinfo *config.TLSInfo, cinfo *ehttp.CORSInfo, handler http.Handler) {
|
|
func serve(who string, addr string, tinfo *config.TLSInfo, cinfo *ehttp.CORSInfo, handler http.Handler) {
|
|
|
t, terr := tinfo.ServerConfig()
|
|
t, terr := tinfo.ServerConfig()
|
|
|
l, err := net.Listen("tcp", addr)
|
|
l, err := net.Listen("tcp", addr)
|