-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
64 lines (49 loc) · 2.57 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
58
59
60
61
62
63
64
package main
import (
"flag"
"github.com/YasnaTeam/callbacker/client"
"github.com/YasnaTeam/callbacker/configurator"
"github.com/YasnaTeam/callbacker/logger"
"github.com/YasnaTeam/callbacker/server"
"github.com/sirupsen/logrus"
)
var isServer bool
var serverAddress string
var serverLocalAddress string
var serverRepresentationalMainUrl string
var serverPort string
var debugMode bool
var logLocation string
var showNotification bool
var log *logrus.Logger
func init() {
flag.BoolVar(&isServer, "server", false, "make instance as a server")
flag.BoolVar(&isServer, "s", false, "make instance as a server")
flag.StringVar(&serverLocalAddress, "host", "127.0.0.1:1616", "set server local address in [http://]address[:port] format")
flag.StringVar(&serverLocalAddress, "a", "127.0.0.1:1616", "set server local address in [http://]address[:port] format")
flag.StringVar(&serverAddress, "callbacker-server", "callback.site:2424", "set server local address in address:port format")
flag.StringVar(&serverAddress, "c", "callback.site:2424", "set server local address in address:port format")
flag.StringVar(&serverRepresentationalMainUrl, "url", "http://callback.site/callback", "A representational url which will be used to client when getting callback url")
flag.StringVar(&serverRepresentationalMainUrl, "u", "http://callback.site/callback", "A representational url which will be used to client when getting callback url")
flag.StringVar(&serverPort, "port", ":2424", "if instance is a server, set the listening port in [callback.site|x.x.x.x:]port format")
flag.StringVar(&serverPort, "p", ":2424", "if instance is a server, set the listening port in [callback.site|x.x.x.x:]port format")
flag.BoolVar(&debugMode, "debug", false, "enable debug mode")
flag.BoolVar(&debugMode, "v", false, "enable debug mode")
flag.BoolVar(&showNotification, "n", false, "Show notification on client for events")
flag.BoolVar(&showNotification, "notification", false, "Show notification on client for events")
flag.StringVar(&logLocation, "log", "/var/log/callbacker/error.log", "set location of error log file")
flag.StringVar(&logLocation, "l", "/var/log/callbacker/error.log", "set location of error log file")
}
func main() {
configurator.PrintBuildInformation()
flag.Parse()
log = logger.New(debugMode)
log.Debug("log module fired up!")
if isServer {
server.Initialize(serverLocalAddress, serverPort, serverRepresentationalMainUrl, log)
} else {
notification := client.NewNotification(showNotification, log)
client.Initialize(serverAddress, log, notification)
}
log.Info("Shutting down...")
}