-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
81 lines (67 loc) · 1.6 KB
/
main.go
File metadata and controls
81 lines (67 loc) · 1.6 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Jablko Core
// Cale Overstreet
// Mar. 30, 2021
// github.com/ccoverstreet/Jablko
// Core Jablko process entrypoint. Responsible for
// proxying requests, authentication, process
// management.
package main
import (
"fmt"
"io/ioutil"
"os"
"github.com/ccoverstreet/Jablko/core/app2"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
)
func main() {
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr}).With().Caller().Logger()
fmt.Printf("%s\b", startingStatement)
// Initialize directory structure that Jablko uses
CreateDirectories()
configBytes, err := ioutil.ReadFile("./jablkoconfig.json")
if err != nil {
log.Warn().Msg("jablkoconfig.json not found. Starting Jablko with default config")
configBytes = []byte(app2.JABLKO_DEFAULT_CONFIG)
err = ioutil.WriteFile("jablkoconfig.json", configBytes, 0644)
if err != nil {
log.Fatal().
Err(err).
Msg("Unable to save default config to file")
}
}
jablkoApp2, err := app2.CreateJablkoApp(configBytes)
if err != nil {
panic(err)
}
log.Printf("%v\n", jablkoApp2)
jablkoApp2.StartJMODs()
jablkoApp2.Run()
}
func CreateDirectories() {
// Make Directories if don't exist
err := os.MkdirAll("./log", 0700)
if err != nil {
log.Error().
Err(err).
Msg("Unable to make log directory")
}
err = os.MkdirAll("./data", 0700)
if err != nil {
log.Error().
Err(err).
Msg("Unable to make log directory")
}
err = os.MkdirAll("./tmp", 0700)
if err != nil {
log.Error().
Err(err).
Msg("Unable to make tmp directory")
}
}
const startingStatement = `
Jablko Smart Home
Cale Overstreet
Version 0.3.0
License: GPLv3
`