/*
 * Copyright 2026 Oleg Borodin <onborodin@gmail.com>
 *
 * This work is published and licensed under a Creative Commons
 * Attribution-NonCommercial-NoDerivatives 4.0 International License.
 *
 * Distribution of this work is permitted, but commercial use and
 * modifications are strictly prohibited.
 */
package main

import (
	"os"

	"mstore/app/logger"
	"mstore/app/server"
)

func run() error {
	var err error
	srv, err := server.NewServer()
	if err != nil {
		return err
	}
	err = srv.Configure()
	if err != nil {
		return err
	}
	err = srv.Daemonize()
	if err != nil {
		return err
	}
	err = srv.Build()
	if err != nil {
		return err
	}
	err = srv.Run()
	if err != nil {
		return err
	}
	return err
}

func main() {
	log := logger.NewLoggerWithSubject("main")
	err := run()
	if err != nil {
		log.Errorf("%v", err)
		os.Exit(1)
	}
	os.Exit(0)
}
