yatwiki/cmd/yatwiki-server/main.go
2017-07-09 11:13:36 +12:00

36 lines
572 B
Go

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)
}