<commit_before>package main

import (
	"flag"

	"os"
	"os/signal"
	"syscall"

	log "github.com/sirupsen/logrus"

	"github.com/gost/server/configuration"
	"github.com/gost/server/database/postgis"
	"github.com/gost/server/http"
	gostLog "github.com/gost/server/log"
	"github.com/gost/server/mqtt"
	"github.com/gost/server/sensorthings/api"
	"github.com/gost/server/sensorthings/models"
)

var (
	stAPI       models.API
	gostServer  http.Server
	mqttClient  models.MQTTClient
	file        *os.File
	logger      *log.Logger
	mainLogger  *log.Entry
	conf        configuration.Config
	cfgFlag     = flag.String("config", "config.yaml", "path of the config file")
	installFlag = flag.String("install", "", "path to the database creation file")
)

func init() {
	flag.Parse()

	cfg := *cfgFlag
	conf, err := configuration.GetConfig(cfg)
	if err != nil {
		log.Fatal("config read error: ", err)
		return
	}

	configuration.SetEnvironmentVariables(&conf)
	logger, err = gostLog.InitializeLogger(file, conf.Logger.FileName, new(log.TextFormatter), conf.Logger.Verbose)
	if err != nil {
		log.Println("Error initializing logger, defaulting to stdout. Error: " + err.Error())
	}

	//Setting default fieleds for main logger
	mainLogger = logger.WithFields(log.Fields{"package": "main"})
}

func main() {
	stop := make(chan os.Signal, 2)
	signal.Notify(stop, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
	go func() {
		<-stop
		cleanup()
		log.Print("GOST stopped gracefully")
		mainLogger.Info("GOST stopped gracefully")
		os.Exit(1)
	}()

	log.Println("Starting GOST....")
	mainLogger.Info("Starting GOST")

	database := postgis.NewDatabase(
		conf.Database.Host,
		conf.Database.Port,
		conf.Database.User,<commit_msg>Fixed reading config from init<commit_after>package main

import (
	"flag"

	"os"
	"os/signal"
	"syscall"

	log "github.com/sirupsen/logrus"

	"github.com/gost/server/configuration"
	"github.com/gost/server/database/postgis"
	"github.com/gost/server/http"
	gostLog "github.com/gost/server/log"
	"github.com/gost/server/mqtt"
	"github.com/gost/server/sensorthings/api"
	"github.com/gost/server/sensorthings/models"
)

var (
	stAPI       models.API
	gostServer  http.Server
	mqttClient  models.MQTTClient
	file        *os.File
	logger      *log.Logger
	mainLogger  *log.Entry
	conf        configuration.Config
	cfgFlag     = flag.String("config", "config.yaml", "path of the config file")
	installFlag = flag.String("install", "", "path to the database creation file")
)

func init() {
	flag.Parse()
	cfg := *cfgFlag
	var err error
	conf, err = configuration.GetConfig(cfg)
	if err != nil {
		log.Fatal("config read error: ", err)
		return
	}

	configuration.SetEnvironmentVariables(&conf)
	logger, err = gostLog.InitializeLogger(file, conf.Logger.FileName, new(log.TextFormatter), conf.Logger.Verbose)
	if err != nil {
		log.Println("Error initializing logger, defaulting to stdout. Error: " + err.Error())
	}

	// Setting default fields for main logger
	mainLogger = logger.WithFields(log.Fields{"package": "main"})
}

func main() {
	stop := make(chan os.Signal, 2)
	signal.Notify(stop, syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
	go func() {
		<-stop
		cleanup()
		log.Print("GOST stopped gracefully")
		mainLogger.Info("GOST stopped gracefully")
		os.Exit(1)
	}()

	log.Println("Starting GOST....")
	mainLogger.Info("Starting GOST")

	database := postgis.NewDatabase(
		conf.Database.Host,
		conf.Database.Port,
		conf.Database.User,
{'fraction_non_alphanumeric': 0.14142283419391852, 'fraction_numerical': 0.0011474469305794606, 'mean_word_length': 4.090510948905109, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2284511', 'n_tokens_mistral': 1301, 'n_tokens_neox': 1227, 'n_words': 250}