package main

import (
	"log"

	"git.paulbsd.com/paulbsd/qrz/src/config"
	"git.paulbsd.com/paulbsd/qrz/src/database"
	"git.paulbsd.com/paulbsd/qrz/src/qrz"
	"git.paulbsd.com/paulbsd/qrz/src/qrzws"
	_ "github.com/go-sql-driver/mysql"
	_ "github.com/lib/pq"
	_ "github.com/mattn/go-sqlite3"
)

var version string

func main() {
	var err error
	var cfg config.Config
	cfg.GetConfig()

	cfg.Version = version

	// Initialize database
	err = database.Initialize(&cfg)
	if err != nil {
		log.Fatalln(err)
	}
	defer cfg.Db.Close()

	// Initialize qrz cron
	err = qrz.InitCronConfig(cfg)
	if err != nil {
		log.Println(err)
	}

	// Run qrzws server
	err = qrzws.RunServer(cfg)
	if err != nil {
		log.Println(err)
	}
}
