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")
|
2017-07-09 00:14:28 +00:00
|
|
|
faviconPath := flag.String("favicon", "", "Local disk path to favicon.ico file (leave blank for no favicon)")
|
2017-07-08 23:13:36 +00:00
|
|
|
flag.Parse()
|
|
|
|
|
|
|
|
opts := yatwiki3.DefaultOptions()
|
|
|
|
opts.DBFilePath = *dbPath
|
2017-07-09 00:14:28 +00:00
|
|
|
opts.FaviconFilePath = *faviconPath
|
2017-07-08 23:13:36 +00:00
|
|
|
|
|
|
|
ws, err := yatwiki3.NewWikiServer(opts)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Fprintln(os.Stderr, err.Error())
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
defer ws.Close()
|
|
|
|
|
2017-07-09 00:14:59 +00:00
|
|
|
fmt.Printf("YATWiki now listening on %s\n", *bindAddr)
|
2017-07-08 23:13:36 +00:00
|
|
|
err = http.ListenAndServe(*bindAddr, ws)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Fprintln(os.Stderr, err.Error())
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
|
|
|
|
os.Exit(0)
|
|
|
|
}
|