-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathmain.go
More file actions
60 lines (49 loc) · 1.11 KB
/
main.go
File metadata and controls
60 lines (49 loc) · 1.11 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
/**
* @author Kief H. Shemul
* @email theshemul@gmail.com
* @create date 2020-06-12 23:40:57
* @modify date 2020-06-12 23:40:57
* @desc go-machinery init
*/
package main
import (
"os"
"github.com/RichardKnop/machinery/v1"
"github.com/shemul/go-machinery/server"
"github.com/shemul/go-machinery/utils"
"github.com/shemul/go-machinery/worker"
"github.com/urfave/cli"
)
var (
app *cli.App
taskserver *machinery.Server
)
func init() {
app = cli.NewApp()
app.Name = "go-machinery"
app.Usage = "machinery worker and send example tasks with machinery send"
app.Author = "Kief H. Shemul"
app.Email = "theshemul@gmail.com"
taskserver = utils.GetMachineryServer()
}
func main() {
app.Commands = []cli.Command{
{
Name: "server",
Usage: "Run the server that takes task input",
Action: func(c *cli.Context) {
utils.Logger.Info("server")
server.StartServer(taskserver)
},
},
{
Name: "worker",
Usage: "Run the worker that will consume tasks",
Action: func(c *cli.Context) {
utils.Logger.Info("worker")
worker.StartWorker(taskserver)
},
},
}
app.Run(os.Args)
}