yats.git

ref: f371af5f199691912f766ce813b5e8df7e5d756c

server/yats.go


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
 * Yats - yats
 *
 * This file is licensed under the Affero General Public License version 3 or
 * later. See the COPYING file.
 *
 * @author Paolo Lulli <kevwe.com>
 * @copyright Paolo Lulli 2024
 */

package main

import (
	"fmt"
	"os"
	"yats-server/config"
	"yats-server/db"
)

var configuration config.Configuration
var instanceName = "default"

func main() {
	args := os.Args
	if len(args) < 2 {
		fmt.Println("Loading default config")
		configuration = config.GetConfig(os.Getenv("HOME") + "/.yats.json")
	} else {
		instanceName = args[1]
		fmt.Printf("Loading instance: [%s] config", instanceName)
		configuration = config.GetConfig(os.Getenv("HOME") + "/.yats/" + instanceName + ".json")
	}

	db.Session = db.InitializeDb(configuration)

	if configuration.IS_ARCHIVE_NODE == "true" {
		go MaintenanceThread(configuration)
	}

	RestService(configuration)
}