Convert config.go into command line params
This commit is contained in:
parent
9d1f1ad5c0
commit
0e8f1e7b56
14 changed files with 217 additions and 189 deletions
36
main.go
36
main.go
|
@ -3,6 +3,7 @@ package main
|
|||
import (
|
||||
log "github.com/cihub/seelog"
|
||||
|
||||
"flag"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
|
@ -11,36 +12,39 @@ import (
|
|||
"gitlab.com/trantor/trantor/lib/storage"
|
||||
)
|
||||
|
||||
const (
|
||||
PORT = "8080"
|
||||
|
||||
DB_IP = "127.0.0.1"
|
||||
DB_NAME = "trantor"
|
||||
|
||||
STORE_PATH = "store/"
|
||||
)
|
||||
|
||||
func main() {
|
||||
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()
|
||||
|
||||
defer log.Flush()
|
||||
err := trantor.UpdateLogger()
|
||||
err := trantor.UpdateLogger(*loggerConfig)
|
||||
if err != nil {
|
||||
log.Error("Error loading the logger xml: ", err)
|
||||
}
|
||||
log.Info("Start the imperial library of trantor")
|
||||
|
||||
db := database.Init(DB_IP, DB_NAME)
|
||||
db := database.Init(*dbIP, *dbName)
|
||||
defer db.Close()
|
||||
|
||||
store, err := storage.Init(STORE_PATH)
|
||||
store, err := storage.Init(*storePath)
|
||||
if err != nil {
|
||||
log.Critical("Problem initializing store: ", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
trantor.InitTasks(db)
|
||||
sg := trantor.InitStats(db, store)
|
||||
template := trantor.InitTemplate(*assetsPath)
|
||||
sg := trantor.InitStats(db, store, *hostname, template)
|
||||
trantor.InitUpload(db, store)
|
||||
trantor.InitTasks(db, *loggerConfig)
|
||||
|
||||
trantor.InitRouter(db, sg)
|
||||
log.Error(http.ListenAndServe(":"+PORT, nil))
|
||||
trantor.InitRouter(db, sg, *assetsPath)
|
||||
log.Error(http.ListenAndServe(*httpAddr, nil))
|
||||
}
|
||||
|
|
Reference in a new issue