2017-10-06 07:02:57 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
"log"
|
|
|
|
"net/http"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"code.ivysaur.me/contented"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
cwd, _ := os.Getwd()
|
|
|
|
|
|
|
|
listenAddr := flag.String("listen", "127.0.0.1:80", "")
|
|
|
|
dataDir := flag.String("data", cwd, "Directory for stored content")
|
|
|
|
dbPath := flag.String("db", "contented.db", "Path for metadata database")
|
|
|
|
appTitle := flag.String("title", "contented", "Title used in web interface")
|
|
|
|
maxUploadMb := flag.Int("max", 8, "Maximum size of uploaded files in MiB (set zero for unlimited)")
|
|
|
|
flag.Parse()
|
|
|
|
|
|
|
|
svr, err := contented.NewServer(&contented.ServerOptions{
|
2017-10-07 05:05:58 +00:00
|
|
|
DataDirectory: *dataDir,
|
|
|
|
DBPath: *dbPath,
|
|
|
|
ServerPublicProperties: contented.ServerPublicProperties{
|
|
|
|
AppTitle: *appTitle,
|
|
|
|
MaxUploadBytes: int64(*maxUploadMb) * 1024 * 1024,
|
|
|
|
},
|
2017-10-06 07:02:57 +00:00
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
log.Println(err.Error())
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = http.ListenAndServe(*listenAddr, svr)
|
|
|
|
if err != nil {
|
|
|
|
log.Println(err.Error())
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
}
|