yatwiki/cmd/yatwiki-server/main.go
2017-07-11 19:08:22 +12:00

42 lines
873 B
Go

package main
import (
"flag"
"fmt"
"net/http"
"os"
"time"
"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")
faviconPath := flag.String("favicon", "", "Local disk path to favicon.ico file (leave blank for no favicon)")
flag.Parse()
opts := yatwiki3.DefaultOptions()
opts.DBFilePath = *dbPath
opts.FaviconFilePath = *faviconPath
opts.Timezone = time.Local.String()
opts.ExternalBaseURL = "http://" + *bindAddr + "/"
ws, err := yatwiki3.NewWikiServer(opts)
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}
defer ws.Close()
fmt.Printf("YATWiki now listening on %s\n", *bindAddr)
err = http.ListenAndServe(*bindAddr, ws)
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
os.Exit(1)
}
os.Exit(0)
}