agent: remove Restart operation

This commit is contained in:
Gyu-Ho Lee 2016-12-13 14:54:49 -08:00
parent 4b3d69835f
commit b709297caa
No known key found for this signature in database
GPG Key ID: 1DDD39C7EB70C24C
3 changed files with 36 additions and 79 deletions

View File

@ -170,7 +170,7 @@ var uploadSig = make(chan Request_Operation, 1)
func (t *transporterServer) Transfer(ctx context.Context, r *Request) (*Response, error) { func (t *transporterServer) Transfer(ctx context.Context, r *Request) (*Response, error) {
peerIPs := strings.Split(r.PeerIPString, "___") peerIPs := strings.Split(r.PeerIPString, "___")
if r.Operation == Request_Start || r.Operation == Request_Restart { if r.Operation == Request_Start {
if !filepath.HasPrefix(etcdDataDir, globalFlags.WorkingDirectory) { if !filepath.HasPrefix(etcdDataDir, globalFlags.WorkingDirectory) {
etcdDataDir = filepath.Join(globalFlags.WorkingDirectory, etcdDataDir) etcdDataDir = filepath.Join(globalFlags.WorkingDirectory, etcdDataDir)
} }
@ -466,45 +466,6 @@ func (t *transporterServer) Transfer(ctx context.Context, r *Request) (*Response
return nil, fmt.Errorf("unknown database %q", r.Database) return nil, fmt.Errorf("unknown database %q", r.Database)
} }
case Request_Restart: // TODO: proxy is not supported!
if t.cmd == nil {
return nil, fmt.Errorf("nil command")
}
plog.Infof("restarting database %q", t.req.Database.String())
if r.Database == Request_ZooKeeper {
if err := os.Chdir(zkWorkingDir); err != nil {
return nil, err
}
}
f, err := openToAppend(databaseLogPath)
if err != nil {
return nil, err
}
t.logfile = f
cmd := exec.Command(t.cmd.Path, t.cmd.Args[1:]...)
cmd.Stdout = f
cmd.Stderr = f
cmdString := strings.Join(t.cmd.Args, " ")
plog.Infof("restarting binary %q", cmdString)
if err := cmd.Start(); err != nil {
return nil, err
}
t.cmd = cmd
t.pid = cmd.Process.Pid
plog.Infof("restarted binary %q [PID: %d]", cmdString, t.pid)
processPID = t.pid
go func() {
if err := cmd.Wait(); err != nil {
plog.Errorf("cmd.Wait %q returned error (%v)", cmdString, err)
return
}
plog.Infof("exiting %q", cmdString)
}()
case Request_Stop: case Request_Stop:
time.Sleep(3 * time.Second) // wait a few more seconds to collect more monitoring data time.Sleep(3 * time.Second) // wait a few more seconds to collect more monitoring data
if t.cmd == nil { if t.cmd == nil {
@ -542,7 +503,7 @@ func (t *transporterServer) Transfer(ctx context.Context, r *Request) (*Response
return nil, fmt.Errorf("Not implemented %v", r.Operation) return nil, fmt.Errorf("Not implemented %v", r.Operation)
} }
if r.Operation == Request_Start || r.Operation == Request_Restart { if r.Operation == Request_Start {
go func(processPID int) { go func(processPID int) {
notifier := make(chan os.Signal, 1) notifier := make(chan os.Signal, 1)
signal.Notify(notifier, syscall.SIGINT, syscall.SIGTERM) signal.Notify(notifier, syscall.SIGINT, syscall.SIGTERM)

View File

@ -42,20 +42,17 @@ type Request_Operation int32
const ( const (
Request_Start Request_Operation = 0 Request_Start Request_Operation = 0
Request_Stop Request_Operation = 1 Request_Stop Request_Operation = 1
Request_Restart Request_Operation = 2
Request_UploadLog Request_Operation = 3 Request_UploadLog Request_Operation = 3
) )
var Request_Operation_name = map[int32]string{ var Request_Operation_name = map[int32]string{
0: "Start", 0: "Start",
1: "Stop", 1: "Stop",
2: "Restart",
3: "UploadLog", 3: "UploadLog",
} }
var Request_Operation_value = map[string]int32{ var Request_Operation_value = map[string]int32{
"Start": 0, "Start": 0,
"Stop": 1, "Stop": 1,
"Restart": 2,
"UploadLog": 3, "UploadLog": 3,
} }
@ -943,38 +940,38 @@ var (
func init() { proto.RegisterFile("agent/message.proto", fileDescriptorMessage) } func init() { proto.RegisterFile("agent/message.proto", fileDescriptorMessage) }
var fileDescriptorMessage = []byte{ var fileDescriptorMessage = []byte{
// 528 bytes of a gzipped FileDescriptorProto // 519 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0x84, 0x93, 0xcf, 0x4e, 0xdb, 0x4c, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02,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xd7, 0xca, 0x33, 0x54, 0x6c, 0x77, 0xf5, 0xaa, 0xf7, 0x1f, 0x95, 0x7a, 0xb1, 0x35, 0xac,
0x3e, 0xf1, 0x9d, 0xff, 0x2a, 0x3d, 0xdf, 0x1a, 0xd6, 0x4e, 0x9e, 0x5c, 0xff, 0x08, 0x6a, 0xd7, 0xb4, 0x9f, 0x5c, 0xfd, 0x0c, 0x2a, 0x57, 0xb3, 0xc0, 0xf9, 0x3e, 0x0b, 0x9c, 0x1f, 0xb3, 0xc0,
0xb3, 0xc0, 0xf9, 0x36, 0x0b, 0x9c, 0xef, 0xb3, 0xc0, 0xf9, 0xfa, 0x33, 0xa8, 0xf5, 0xd7, 0xec, 0xf9, 0xf6, 0x2b, 0xa8, 0xf4, 0x37, 0xec, 0xbf, 0xd6, 0xfa, 0x13, 0x00, 0x00, 0xff, 0xff, 0x2f,
0x8f, 0x77, 0xf8, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x0a, 0xb2, 0x57, 0xe6, 0xc5, 0x03, 0x00, 0x00, 0xc9, 0x22, 0xaf, 0xb8, 0x03, 0x00, 0x00,
} }

View File

@ -16,7 +16,6 @@ message Request {
enum Operation { enum Operation {
Start = 0; Start = 0;
Stop = 1; Stop = 1;
Restart = 2;
UploadLog = 3; UploadLog = 3;
} }
enum Database { enum Database {