-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
54 lines (47 loc) · 969 Bytes
/
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
package main
import (
"github.com/tanggalnya/queue-actor/cmd"
"log"
"os"
"github.com/tanggalnya/queue-actor/internal/handlers"
)
var (
server = "server"
worker = "worker"
)
func main() {
currentPath, err := os.Getwd()
if err != nil {
log.Panic(err)
}
arg := os.Args[1]
switch arg {
case server:
err := cmd.InitAppBase(currentPath)
if err != nil {
log.Panicf("Cannot spawn server, err: %v", err.Error())
return
}
r := handlers.SetupRouter()
err = r.Run(":8085")
if err != nil {
log.Panicf("Cannot spawn server, err: %v", err.Error())
return
}
case worker:
err := cmd.InitWorkerBase(currentPath)
if err != nil {
log.Panicf("Cannot spawn worker, err: %v", err.Error())
return
}
wd, err := cmd.InitWorkerDependencies()
err = wd.EventsSubscribers.Triggers.Process()
if err != nil {
log.Panicf("Cannot spawn worker, err: %v", err.Error())
return
}
default:
log.Panicln("Need 1 args")
return
}
}