aboutsummaryrefslogtreecommitdiff
path: root/cmd/web.go
diff options
context:
space:
mode:
Diffstat (limited to 'cmd/web.go')
-rw-r--r--cmd/web.go25
1 files changed, 18 insertions, 7 deletions
diff --git a/cmd/web.go b/cmd/web.go
index 51f146f3..8e75e8be 100644
--- a/cmd/web.go
+++ b/cmd/web.go
@@ -25,6 +25,7 @@ import (
"github.com/macaron-contrib/oauth2"
"github.com/macaron-contrib/session"
"github.com/macaron-contrib/toolbox"
+ "gopkg.in/ini.v1"
api "github.com/gogits/go-gogs-client"
@@ -52,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 {
@@ -74,11 +77,13 @@ func checkVersion() {
// Check dependency version.
checkers := []VerChecker{
- {"github.com/Unknwon/macaron", macaron.Version, "0.4.9"},
+ {"github.com/Unknwon/macaron", macaron.Version, "0.5.1"},
{"github.com/macaron-contrib/binding", binding.Version, "0.0.4"},
+ {"github.com/macaron-contrib/cache", cache.Version, "0.0.7"},
{"github.com/macaron-contrib/csrf", csrf.Version, "0.0.1"},
{"github.com/macaron-contrib/i18n", i18n.Version, "0.0.5"},
- {"github.com/macaron-contrib/session", session.Version, "0.1.1"},
+ {"github.com/macaron-contrib/session", session.Version, "0.1.6"},
+ {"gopkg.in/ini.v1", ini.Version, "1.2.0"},
}
for _, c := range checkers {
ver := strings.Join(strings.Split(c.Version(), ".")[:3], ".")
@@ -159,7 +164,7 @@ func newMacaron() *macaron.Macaron {
return m
}
-func runWeb(*cli.Context) {
+func runWeb(ctx *cli.Context) {
routers.GlobalInit()
checkVersion()
@@ -176,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)
@@ -457,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)