-
Notifications
You must be signed in to change notification settings - Fork 2k
/
automation_server.go
47 lines (39 loc) · 1.04 KB
/
automation_server.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
// Copyright 2015, Google Inc. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package main
import (
"flag"
"fmt"
"net"
"os"
"google.golang.org/grpc"
"github.com/youtube/vitess/go/vt/automation"
automationservicepb "github.com/youtube/vitess/go/vt/proto/automationservice"
"github.com/youtube/vitess/go/vt/servenv"
)
func init() {
servenv.RegisterDefaultFlags()
}
func main() {
flag.Parse()
fmt.Println("Automation Server, listening on:", *servenv.Port)
if *servenv.Port == 0 {
fmt.Println("No port specified using --port.")
os.Exit(1)
}
listener, err := net.Listen("tcp", fmt.Sprintf(":%v", *servenv.Port))
if err != nil {
fmt.Printf("Failed to listen: %v", err)
os.Exit(2)
}
grpcServer := grpc.NewServer()
scheduler, err := automation.NewScheduler()
if err != nil {
fmt.Printf("Failed to create scheduler: %v", err)
os.Exit(3)
}
scheduler.Run()
automationservicepb.RegisterAutomationServer(grpcServer, scheduler)
grpcServer.Serve(listener)
}