-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
49 lines (43 loc) · 847 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
package main
import (
"log"
_ "net/http/pprof"
"os"
"github.com/Tech-With-Tim/Socket-Api/server"
"github.com/urfave/cli/v2"
)
var app = cli.NewApp()
func main() {
commands()
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}
func commands() {
app.Commands = []*cli.Command{
{
Name: "runserver",
Usage: "Run Api Server",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "host",
Usage: "Host on which server has to be run",
Value: "localhost",
Aliases: []string{"H"},
},
&cli.IntFlag{
Name: "port",
Usage: "Port on which server has to be run",
Value: 5000,
Aliases: []string{"P"},
},
},
Action: func(c *cli.Context) error {
s := server.CreateServer()
err := s.RunServer(c.String("host"), c.Int("port"))
return err
},
},
}
}