39 lines
776 B
Go
39 lines
776 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")
|
|
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
|
|
|
|
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)
|
|
}
|