-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
57 lines (44 loc) · 1.08 KB
/
main.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// An API to provide information about the world FOREX markets
// Started 27 May 2018
// Governed by the license that can be found in the repository LICENSE file
package main
import (
"os"
"os/signal"
// Internal
"github.com/deezone/forex-clock/config"
"github.com/deezone/forex-clock/server"
// Third-party
log "github.com/sirupsen/logrus"
)
// Main function
// Starting point for application - `go run`
func main() {
m := "Starting forex-clock application..."
log.Info(m)
// Initialize configuration
config.Init()
m = "Configuration loaded..."
log.Info(m)
// Create new server
s := server.NewServer()
m = "Creating new server..."
log.Info(m)
// Start server
m = "Starting server..."
log.Info(m)
if err := s.Start(); err != nil {
panic("Error starting application. Error was: " + err.Error())
}
// Listen for and exit the application on SIGKILL or SIGINT
stop := make(chan os.Signal)
signal.Notify(stop, os.Interrupt, os.Kill)
select {
case <-stop:
// Attempt to stop the server
s.Stop()
// Log shut down
m = "Server is shutting down..."
log.Info(m)
}
}