minor bugfixes and cleanup
This commit is contained in:
parent
2a203f6f29
commit
97d914bce4
26 changed files with 198 additions and 221 deletions
|
|
@ -3,7 +3,6 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"git.giftfish.de/ston1th/godrop"
|
||||
"github.com/urfave/cli"
|
||||
stdlog "log"
|
||||
|
|
@ -13,13 +12,12 @@ import (
|
|||
"syscall"
|
||||
"time"
|
||||
|
||||
"git.giftfish.de/ston1th/gowiki/pkg/core"
|
||||
"git.giftfish.de/ston1th/gowiki/pkg/log"
|
||||
"git.giftfish.de/ston1th/gowiki/pkg/server"
|
||||
)
|
||||
|
||||
const (
|
||||
blevePath = "bleve"
|
||||
|
||||
defDataDir = "/var/lib/gowiki"
|
||||
defListen = "127.0.0.1:8090"
|
||||
defLogFile = "gowiki.log"
|
||||
|
|
@ -28,7 +26,7 @@ const (
|
|||
defRunGroup = "wiki"
|
||||
)
|
||||
|
||||
func initServer(conf serverConfig) (err error) {
|
||||
func initServer(conf core.Config) (err error) {
|
||||
dropCfg := godrop.Config{
|
||||
User: conf.User,
|
||||
Group: conf.Group,
|
||||
|
|
@ -51,7 +49,7 @@ func initServer(conf serverConfig) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
srv := server.NewHTTPServer(l, conf.Version, conf.DataDir+"/"+blevePath, conf.SecureCookie)
|
||||
srv := server.NewHTTPServer(l, conf)
|
||||
err = srv.Start()
|
||||
if err != nil {
|
||||
return
|
||||
|
|
@ -63,8 +61,7 @@ func initServer(conf serverConfig) (err error) {
|
|||
log.Println("caught " + sig.String())
|
||||
go func() {
|
||||
time.Sleep(time.Second * 20)
|
||||
//TODO error needed?
|
||||
log.Fatal(errors.New("stop timed out: killing"))
|
||||
log.Fatal("stop timed out: killing")
|
||||
}()
|
||||
err = srv.Stop()
|
||||
if err != nil {
|
||||
|
|
@ -76,7 +73,7 @@ func initServer(conf serverConfig) (err error) {
|
|||
|
||||
var (
|
||||
verbose bool
|
||||
conf serverConfig
|
||||
conf core.Config
|
||||
)
|
||||
|
||||
func Run(version string) {
|
||||
|
|
@ -131,17 +128,6 @@ func Run(version string) {
|
|||
app.Run(os.Args)
|
||||
}
|
||||
|
||||
type serverConfig struct {
|
||||
DataDir string
|
||||
User string
|
||||
Group string
|
||||
ListenAddr string
|
||||
LogFile string
|
||||
Version string
|
||||
Foreground bool
|
||||
SecureCookie bool
|
||||
}
|
||||
|
||||
func serverFlags() []cli.Flag {
|
||||
return []cli.Flag{
|
||||
cli.StringFlag{
|
||||
|
|
@ -168,6 +154,11 @@ func serverFlags() []cli.Flag {
|
|||
Usage: "log file (leave empty for stdout, this only works in combination with -f)",
|
||||
Destination: &conf.LogFile,
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "secret",
|
||||
Usage: "static hmac secret (at least 64 chars, used for JWT signing)",
|
||||
Destination: &conf.Secret,
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "foreground, f",
|
||||
Usage: "do not fork into the background",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue