Moving port parameter to servenv.

This commit is contained in:
Alain Jobart 2014-03-06 10:31:49 -08:00
Родитель 500c34e604
Коммит de8060b3f1
8 изменённых файлов: 16 добавлений и 20 удалений

Просмотреть файл

@ -22,7 +22,6 @@ import (
)
var (
port = flag.Int("port", 0, "port for debug http server")
action = flag.String("action", "", "management action to perform")
actionNode = flag.String("action-node", "", "path to zk node representing the action")
actionGuid = flag.String("action-guid", "", "a label to help track processes")
@ -65,7 +64,7 @@ func main() {
// we delegate out startup to the micromanagement server so these actions
// will occur after we have obtained our socket.
bindAddr := fmt.Sprintf(":%v", *port)
bindAddr := fmt.Sprintf(":%v", *servenv.Port)
httpServer := &http.Server{Addr: bindAddr}
go func() {
if err := httpServer.ListenAndServe(); err != nil {

Просмотреть файл

@ -21,7 +21,6 @@ import (
)
var (
port = flag.Int("port", 8080, "port for the server")
templateDir = flag.String("templates", "", "directory containing templates")
debug = flag.Bool("debug", false, "recompile templates for every request")
)
@ -630,5 +629,5 @@ func main() {
}
http.Redirect(w, r, target, http.StatusFound)
})
servenv.Run(*port)
servenv.Run()
}

Просмотреть файл

@ -15,7 +15,6 @@ import (
)
var (
port = flag.Int("port", 8085, "serving port")
cell = flag.String("cell", "test_nj", "cell to use")
retryDelay = flag.Duration("retry-delay", 200*time.Millisecond, "retry delay")
retryCount = flag.Int("retry-count", 10, "retry count")
@ -40,5 +39,5 @@ func main() {
topo.RegisterTopoReader(topoReader)
vtgate.Init(rts, *cell, *retryDelay, *retryCount, *timeout)
servenv.Run(*port)
servenv.Run()
}

Просмотреть файл

@ -18,7 +18,6 @@ import (
)
var (
port = flag.Int("port", 6510, "tcp port to serve on")
overridesFile = flag.String("schema-override", "", "schema overrides file")
enableRowcache = flag.Bool("enable-rowcache", false, "enable rowcacche")
enableInvalidator = flag.Bool("enable-invalidator", false, "enable rowcache invalidator")
@ -53,12 +52,12 @@ func main() {
ts.AllowQueries(&dbConfigs.App, schemaOverrides, ts.LoadCustomRules(), mysqld)
log.Infof("starting vtocc %v", *port)
log.Infof("starting vtocc %v", *servenv.Port)
servenv.OnClose(func() {
time.Sleep(5 * time.Millisecond)
ts.DisallowQueries()
})
servenv.Run(*port)
servenv.Run()
}
func unmarshalFile(name string, val interface{}) {

Просмотреть файл

@ -21,7 +21,6 @@ import (
)
var (
port = flag.Int("port", 6509, "port for the server")
tabletPath = flag.String("tablet-path", "", "tablet alias or path to zk node representing the tablet")
mycnfFile = flag.String("mycnf-file", "", "my.cnf file")
enableRowcache = flag.Bool("enable-rowcache", false, "enable rowcacche")
@ -57,7 +56,7 @@ func main() {
binlog.RegisterUpdateStreamService(mycnf)
// Depends on both query and updateStream.
agent, err = vttablet.InitAgent(tabletAlias, dbcfgs, mycnf, *port, *servenv.SecurePort, *overridesFile)
agent, err = vttablet.InitAgent(tabletAlias, dbcfgs, mycnf, *servenv.Port, *servenv.SecurePort, *overridesFile)
if err != nil {
log.Fatal(err)
}
@ -70,5 +69,5 @@ func main() {
topo.CloseServers()
agent.Stop()
})
servenv.Run(*port)
servenv.Run()
}

Просмотреть файл

@ -31,7 +31,6 @@ import (
var (
cell = flag.String("cell", "", "cell to pick servers from")
port = flag.Int("port", 8080, "port for the status / interactive mode")
)
// signal handling, centralized here
@ -98,5 +97,5 @@ func main() {
}
initStatusHandling()
servenv.Run(*port)
servenv.Run()
}

Просмотреть файл

@ -23,7 +23,6 @@ request to connect.
var (
resolveLocal = flag.Bool("resolve-local", false, "if specified, will try to resolve /zk/local/ paths. If not set, they will fail.")
port = flag.Int("port", 14850, "port for the server")
)
func init() {
@ -43,5 +42,5 @@ func main() {
zk.RegisterZkReader(zkr)
topo.RegisterTopoReader(&TopoReader{zkr: zkr})
servenv.Run(*port)
servenv.Run()
}

Просмотреть файл

@ -1,6 +1,7 @@
package servenv
import (
"flag"
"fmt"
"net/http"
"net/url"
@ -14,18 +15,20 @@ import (
var (
onCloseHooks hooks
Port = flag.Int("port", 0, "port for the server")
// filled in when calling Run or RunSecure
ListeningURL url.URL
)
// Run starts listening for RPC and HTTP requests on the given port,
// Run starts listening for RPC and HTTP requests,
// and blocks until it the process gets a signal.
// It may also listen on a secure port, or on a unix socket.
func Run(port int) {
func Run() {
onRunHooks.Fire()
ServeRPC()
l, err := proc.Listen(fmt.Sprintf("%v", port))
l, err := proc.Listen(fmt.Sprintf("%v", *Port))
if err != nil {
log.Fatal(err)
}
@ -39,7 +42,7 @@ func Run(port int) {
}
ListeningURL = url.URL{
Scheme: "http",
Host: fmt.Sprintf("%v:%v", host, port),
Host: fmt.Sprintf("%v:%v", host, *Port),
Path: "/",
}