diff options
author | Unknwon <joe2010xtmf@163.com> | 2015-02-01 12:41:03 -0500 |
---|---|---|
committer | Unknwon <joe2010xtmf@163.com> | 2015-02-01 12:41:03 -0500 |
commit | b293b6eaa6b305bbac2147f76d5722607e8aa04b (patch) | |
tree | 92e60483c65594729b7bbcf60ca9d15b1932be1f /cmd | |
parent | 3d9cda2d98940102b1bdffc053e036cc696b9f8e (diff) | |
download | gitea-b293b6eaa6b305bbac2147f76d5722607e8aa04b.tar.gz gitea-b293b6eaa6b305bbac2147f76d5722607e8aa04b.zip |
cmd: CMD option for port number of `gogs web` to prevent first time run conflict
- routers: use new binding convention to simplify code
- templates: able to set HTTP port number in install page
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/web.go | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/cmd/web.go b/cmd/web.go index 241abf2c9c..e6fb2925cf 100644 --- a/cmd/web.go +++ b/cmd/web.go @@ -53,7 +53,9 @@ var CmdWeb = cli.Command{ Description: `Gogs web server is the only thing you need to run, and it takes care of all the other things for you`, Action: runWeb, - Flags: []cli.Flag{}, + Flags: []cli.Flag{ + cli.StringFlag{"port, p", "3000", "Temporary port number to prevent conflict", ""}, + }, } type VerChecker struct { @@ -162,7 +164,7 @@ func newMacaron() *macaron.Macaron { return m } -func runWeb(*cli.Context) { +func runWeb(ctx *cli.Context) { routers.GlobalInit() checkVersion() @@ -179,9 +181,9 @@ func runWeb(*cli.Context) { // Routers. m.Get("/", ignSignIn, routers.Home) m.Get("/explore", ignSignIn, routers.Explore) - // FIXME: when i'm binding form here??? - m.Get("/install", bindIgnErr(auth.InstallForm{}), routers.Install) - m.Post("/install", bindIgnErr(auth.InstallForm{}), routers.InstallPost) + m.Combo("/install", routers.InstallInit). + Get(routers.Install). + Post(bindIgnErr(auth.InstallForm{}), routers.InstallPost) m.Group("", func() { m.Get("/pulls", user.Pulls) m.Get("/issues", user.Issues) @@ -460,6 +462,12 @@ func runWeb(*cli.Context) { // Not found handler. m.NotFound(routers.NotFound) + // Flag for port number in case first time run conflict. + if ctx.IsSet("port") { + setting.AppUrl = strings.Replace(setting.AppUrl, setting.HttpPort, ctx.String("port"), 1) + setting.HttpPort = ctx.String("port") + } + var err error listenAddr := fmt.Sprintf("%s:%s", setting.HttpAddr, setting.HttpPort) log.Info("Listen: %v://%s%s", setting.Protocol, listenAddr, setting.AppSubUrl) |