Merge pull request #905 from phsmit/conf_on_cli
Add option to provide configuration file on command line
This commit is contained in:
commit
cd0ee35b3f
8 changed files with 37 additions and 13 deletions
|
@ -26,10 +26,14 @@ It can be used for backup and capture Gogs server image to send to maintainer`,
|
|||
Action: runDump,
|
||||
Flags: []cli.Flag{
|
||||
cli.BoolFlag{"verbose, v", "show process details", ""},
|
||||
cli.StringFlag{"config, c", "custom/conf/app.ini", "Configuration file", ""},
|
||||
},
|
||||
}
|
||||
|
||||
func runDump(ctx *cli.Context) {
|
||||
if ctx.IsSet("config") {
|
||||
setting.CustomConf = ctx.String("config")
|
||||
}
|
||||
setting.NewConfigContext()
|
||||
models.LoadModelsConfig()
|
||||
models.SetEngine()
|
||||
|
|
|
@ -27,7 +27,9 @@ var CmdServ = cli.Command{
|
|||
Usage: "This command should only be called by SSH shell",
|
||||
Description: `Serv provide access auth for repositories`,
|
||||
Action: runServ,
|
||||
Flags: []cli.Flag{},
|
||||
Flags: []cli.Flag{
|
||||
cli.StringFlag{"config, c", "custom/conf/app.ini", "Configuration file", ""},
|
||||
},
|
||||
}
|
||||
|
||||
func setup(logPath string) {
|
||||
|
@ -83,6 +85,9 @@ func In(b string, sl map[string]models.AccessType) bool {
|
|||
}
|
||||
|
||||
func runServ(k *cli.Context) {
|
||||
if k.IsSet("config") {
|
||||
setting.CustomConf = k.String("config")
|
||||
}
|
||||
setup("serv.log")
|
||||
|
||||
keys := strings.Split(os.Args[2], "-")
|
||||
|
|
|
@ -11,6 +11,7 @@ import (
|
|||
|
||||
"github.com/gogits/gogs/models"
|
||||
"github.com/gogits/gogs/modules/log"
|
||||
"github.com/gogits/gogs/modules/setting"
|
||||
)
|
||||
|
||||
var CmdUpdate = cli.Command{
|
||||
|
@ -18,10 +19,15 @@ var CmdUpdate = cli.Command{
|
|||
Usage: "This command should only be called by SSH shell",
|
||||
Description: `Update get pushed info and insert into database`,
|
||||
Action: runUpdate,
|
||||
Flags: []cli.Flag{},
|
||||
Flags: []cli.Flag{
|
||||
cli.StringFlag{"config, c", "custom/conf/app.ini", "Configuration file", ""},
|
||||
},
|
||||
}
|
||||
|
||||
func runUpdate(c *cli.Context) {
|
||||
if c.IsSet("config") {
|
||||
setting.CustomConf = c.String("config")
|
||||
}
|
||||
cmd := os.Getenv("SSH_ORIGINAL_COMMAND")
|
||||
if cmd == "" {
|
||||
return
|
||||
|
|
|
@ -55,6 +55,7 @@ and it takes care of all the other things for you`,
|
|||
Action: runWeb,
|
||||
Flags: []cli.Flag{
|
||||
cli.StringFlag{"port, p", "3000", "Temporary port number to prevent conflict", ""},
|
||||
cli.StringFlag{"config, c", "custom/conf/app.ini", "Configuration file", ""},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -165,6 +166,9 @@ func newMacaron() *macaron.Macaron {
|
|||
}
|
||||
|
||||
func runWeb(ctx *cli.Context) {
|
||||
if ctx.IsSet("config") {
|
||||
setting.CustomConf = ctx.String("config")
|
||||
}
|
||||
routers.GlobalInit()
|
||||
checkVersion()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue