2020-12-08 21:05:30 +01:00
|
|
|
//go:generate packr2 -v
|
|
|
|
|
2019-09-07 11:58:52 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
|
2020-01-29 12:25:06 +01:00
|
|
|
"git.paulbsd.com/paulbsd/qrz/src/config"
|
2020-05-09 19:09:27 +02:00
|
|
|
"git.paulbsd.com/paulbsd/qrz/src/database"
|
2020-01-29 12:25:06 +01:00
|
|
|
"git.paulbsd.com/paulbsd/qrz/src/qrz"
|
2020-05-09 19:09:27 +02:00
|
|
|
"git.paulbsd.com/paulbsd/qrz/src/qrzws"
|
2020-12-08 21:05:30 +01:00
|
|
|
"github.com/gobuffalo/packr/v2"
|
2020-06-01 14:34:37 +02:00
|
|
|
_ "github.com/lib/pq"
|
2020-12-26 17:31:13 +01:00
|
|
|
_ "github.com/spf13/cobra"
|
2019-09-07 11:58:52 +02:00
|
|
|
)
|
|
|
|
|
2020-05-23 12:32:36 +02:00
|
|
|
var version string
|
|
|
|
|
2019-09-07 11:58:52 +02:00
|
|
|
func main() {
|
2020-06-01 14:34:37 +02:00
|
|
|
var cfg config.Config
|
|
|
|
cfg.GetConfig()
|
2020-12-27 15:07:06 +01:00
|
|
|
|
2020-06-01 14:34:37 +02:00
|
|
|
cfg.Version = version
|
2019-09-07 11:58:52 +02:00
|
|
|
|
2020-12-27 15:07:06 +01:00
|
|
|
// Generate static files embedding
|
2020-12-08 21:05:30 +01:00
|
|
|
PackrGen()
|
|
|
|
|
2020-06-01 14:34:37 +02:00
|
|
|
err := database.Initialize(&cfg)
|
2020-07-19 19:32:22 +02:00
|
|
|
if err != nil {
|
|
|
|
log.Fatalln(err)
|
|
|
|
}
|
2020-06-01 17:00:46 +02:00
|
|
|
defer cfg.Db.Close()
|
2019-09-07 11:58:52 +02:00
|
|
|
|
2020-06-01 14:34:37 +02:00
|
|
|
err = qrz.InitCronConfig(cfg)
|
2019-09-07 11:58:52 +02:00
|
|
|
if err != nil {
|
2020-12-27 15:07:06 +01:00
|
|
|
log.Println(err)
|
2019-09-07 11:58:52 +02:00
|
|
|
}
|
|
|
|
|
2020-06-01 14:34:37 +02:00
|
|
|
err = qrzws.RunServer(cfg)
|
2020-02-29 17:37:01 +01:00
|
|
|
if err != nil {
|
2020-12-27 15:07:06 +01:00
|
|
|
log.Println(err)
|
2020-02-29 17:37:01 +01:00
|
|
|
}
|
2019-09-07 11:58:52 +02:00
|
|
|
}
|
2020-12-08 21:05:30 +01:00
|
|
|
|
2020-12-27 15:07:06 +01:00
|
|
|
// PackrGen act as an assets bundle maker
|
2020-12-08 21:05:30 +01:00
|
|
|
func PackrGen() {
|
|
|
|
packr.New("static", "../../static")
|
|
|
|
packr.New("templates", "../../templates")
|
|
|
|
}
|