yatwiki/cmd/yatwiki-server/main.go

36 lines
572 B
Go
Raw Normal View History

2017-07-08 23:13:36 +00:00
package main
import (
"flag"
"fmt"
"net/http"
"os"
"code.ivysaur.me/yatwiki3"
)
func main() {
bindAddr := flag.String("listen", "127.0.0.1:80", "Bind address")
dbPath := flag.String("database", "wiki.db", "Database file")
flag.Parse()
opts := yatwiki3.DefaultOptions()
opts.DBFilePath = *dbPath
ws, err := yatwiki3.NewWikiServer(opts)
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}
defer ws.Close()
err = http.ListenAndServe(*bindAddr, ws)
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}
os.Exit(0)
}