Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
cb5c7526
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
1 年多 前同步成功
通知
696
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
cb5c7526
编写于
7月 25, 2017
作者:
H
Helin Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
shutdown master server gracefully
上级
2200ff5e
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
47 addition
and
4 deletion
+47
-4
go/cmd/master/master.go
go/cmd/master/master.go
+24
-4
go/master/etcd_client.go
go/master/etcd_client.go
+17
-0
go/master/inmem_store.go
go/master/inmem_store.go
+5
-0
go/master/service.go
go/master/service.go
+1
-0
未找到文件。
go/cmd/master/master.go
浏览文件 @
cb5c7526
...
@@ -19,6 +19,8 @@ import (
...
@@ -19,6 +19,8 @@ import (
"net"
"net"
"net/http"
"net/http"
"net/rpc"
"net/rpc"
"os"
"os/signal"
"strconv"
"strconv"
"strings"
"strings"
"time"
"time"
...
@@ -68,6 +70,20 @@ func main() {
...
@@ -68,6 +70,20 @@ func main() {
store
=
&
master
.
InMemStore
{}
store
=
&
master
.
InMemStore
{}
}
}
shutdown
:=
func
()
{
log
.
Infoln
(
"shutting down gracefully"
)
e
:=
store
.
Shutdown
()
if
e
!=
nil
{
log
.
Errorln
(
e
)
}
}
// Guaranteed to run even panic happens.
defer
shutdown
()
c
:=
make
(
chan
os
.
Signal
,
1
)
signal
.
Notify
(
c
,
os
.
Interrupt
)
s
,
err
:=
master
.
NewService
(
store
,
*
chunkPerTask
,
*
taskTimeoutDur
,
*
taskTimeoutMax
)
s
,
err
:=
master
.
NewService
(
store
,
*
chunkPerTask
,
*
taskTimeoutDur
,
*
taskTimeoutMax
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Fatal
(
err
)
log
.
Fatal
(
err
)
...
@@ -84,8 +100,12 @@ func main() {
...
@@ -84,8 +100,12 @@ func main() {
log
.
Fatal
(
err
)
log
.
Fatal
(
err
)
}
}
go
func
()
{
err
=
http
.
Serve
(
l
,
nil
)
err
=
http
.
Serve
(
l
,
nil
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Fatal
(
err
)
log
.
Fatal
(
err
)
}
}
}()
<-
c
}
}
go/master/etcd_client.go
浏览文件 @
cb5c7526
...
@@ -39,6 +39,7 @@ type EtcdClient struct {
...
@@ -39,6 +39,7 @@ type EtcdClient struct {
statePath
string
statePath
string
client
*
clientv3
.
Client
client
*
clientv3
.
Client
lock
*
concurrency
.
Mutex
lock
*
concurrency
.
Mutex
sess
*
concurrency
.
Session
}
}
// NewEtcdClient creates a new EtcdClient.
// NewEtcdClient creates a new EtcdClient.
...
@@ -89,6 +90,7 @@ func NewEtcdClient(endpoints []string, addr string, lockPath, addrPath, statePat
...
@@ -89,6 +90,7 @@ func NewEtcdClient(endpoints []string, addr string, lockPath, addrPath, statePat
statePath
:
statePath
,
statePath
:
statePath
,
client
:
cli
,
client
:
cli
,
lock
:
lock
,
lock
:
lock
,
sess
:
sess
,
}
}
return
e
,
nil
return
e
,
nil
...
@@ -157,6 +159,21 @@ func (e *EtcdClient) Load() ([]byte, error) {
...
@@ -157,6 +159,21 @@ func (e *EtcdClient) Load() ([]byte, error) {
return
state
,
nil
return
state
,
nil
}
}
// Shutdown shuts down the etcd client gracefully.
func
(
e
*
EtcdClient
)
Shutdown
()
error
{
err
:=
e
.
sess
.
Close
()
newErr
:=
e
.
client
.
Close
()
if
newErr
!=
nil
{
if
err
==
nil
{
err
=
newErr
}
else
{
log
.
Errorln
(
newErr
)
}
}
return
err
}
// GetKey gets the value by the specify key.
// GetKey gets the value by the specify key.
func
GetKey
(
c
*
clientv3
.
Client
,
key
string
,
timeout
time
.
Duration
)
(
string
,
error
)
{
func
GetKey
(
c
*
clientv3
.
Client
,
key
string
,
timeout
time
.
Duration
)
(
string
,
error
)
{
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
timeout
)
ctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
timeout
)
...
...
go/master/inmem_store.go
浏览文件 @
cb5c7526
...
@@ -40,3 +40,8 @@ func (m *InMemStore) Load() ([]byte, error) {
...
@@ -40,3 +40,8 @@ func (m *InMemStore) Load() ([]byte, error) {
return
m
.
buf
,
nil
return
m
.
buf
,
nil
}
}
// Shutdown shuts down the in mem store.
func
(
m
*
InMemStore
)
Shutdown
()
error
{
return
nil
}
go/master/service.go
浏览文件 @
cb5c7526
...
@@ -50,6 +50,7 @@ var ErrPassAfter = errors.New("pass number larger than master")
...
@@ -50,6 +50,7 @@ var ErrPassAfter = errors.New("pass number larger than master")
type
Store
interface
{
type
Store
interface
{
Save
([]
byte
)
error
Save
([]
byte
)
error
Load
()
([]
byte
,
error
)
Load
()
([]
byte
,
error
)
Shutdown
()
error
}
}
// Chunk is a chunk of data consisted of several data instances.
// Chunk is a chunk of data consisted of several data instances.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录