2016-05-02 21:36:49 -04:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
log "github.com/cihub/seelog"
|
|
|
|
|
2016-05-03 01:03:23 -04:00
|
|
|
"flag"
|
2016-05-02 21:36:49 -04:00
|
|
|
"net/http"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"gitlab.com/trantor/trantor/lib"
|
|
|
|
"gitlab.com/trantor/trantor/lib/database"
|
|
|
|
"gitlab.com/trantor/trantor/lib/storage"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2016-05-03 01:03:23 -04:00
|
|
|
var (
|
|
|
|
httpAddr = flag.String("addr", ":8080", "HTTP service address")
|
|
|
|
dbIP = flag.String("db-ip", "127.0.0.1", "IP address of the database")
|
|
|
|
dbName = flag.String("db-name", "trantor", "Name of the database")
|
|
|
|
storePath = flag.String("store", "store", "Path of the books storage")
|
|
|
|
assetsPath = flag.String("assets", ".", "Path of the assets (templates, css, js, img)")
|
|
|
|
hostname = flag.String("hostname", "xfmro77i3lixucja.onion", "Hostname of the website")
|
|
|
|
loggerConfig = flag.String("logger-conf", "logger.xml", "xml configuration of the logger")
|
|
|
|
)
|
|
|
|
flag.Parse()
|
|
|
|
|
2016-05-02 21:36:49 -04:00
|
|
|
defer log.Flush()
|
2016-05-03 01:03:23 -04:00
|
|
|
err := trantor.UpdateLogger(*loggerConfig)
|
2016-05-02 21:36:49 -04:00
|
|
|
if err != nil {
|
|
|
|
log.Error("Error loading the logger xml: ", err)
|
|
|
|
}
|
|
|
|
log.Info("Start the imperial library of trantor")
|
|
|
|
|
2016-05-03 01:03:23 -04:00
|
|
|
db := database.Init(*dbIP, *dbName)
|
2016-05-02 21:36:49 -04:00
|
|
|
defer db.Close()
|
|
|
|
|
2016-05-03 01:03:23 -04:00
|
|
|
store, err := storage.Init(*storePath)
|
2016-05-02 21:36:49 -04:00
|
|
|
if err != nil {
|
|
|
|
log.Critical("Problem initializing store: ", err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
|
2016-05-03 01:03:23 -04:00
|
|
|
template := trantor.InitTemplate(*assetsPath)
|
|
|
|
sg := trantor.InitStats(db, store, *hostname, template)
|
2016-05-02 21:36:49 -04:00
|
|
|
trantor.InitUpload(db, store)
|
2016-05-03 01:03:23 -04:00
|
|
|
trantor.InitTasks(db, *loggerConfig)
|
2016-05-02 21:36:49 -04:00
|
|
|
|
2016-05-03 01:03:23 -04:00
|
|
|
trantor.InitRouter(db, sg, *assetsPath)
|
|
|
|
log.Error(http.ListenAndServe(*httpAddr, nil))
|
2016-05-02 21:36:49 -04:00
|
|
|
}
|