fix nil raft server caused crash

fix https://github.com/chrislusf/seaweedfs/issues/524
This commit is contained in:
Chris Lu 2017-07-03 22:35:28 -07:00
parent 1fbb8723dc
commit f9a1769df1
2 changed files with 10 additions and 9 deletions

View file

@ -3,26 +3,25 @@ package weed_server
import (
"net/http"
"github.com/chrislusf/raft"
ui "github.com/chrislusf/seaweedfs/weed/server/master_ui"
"github.com/chrislusf/seaweedfs/weed/stats"
"github.com/chrislusf/seaweedfs/weed/util"
ui "github.com/chrislusf/seaweedfs/weed/server/master_ui"
)
func (ms *MasterServer) uiStatusHandler(w http.ResponseWriter, r *http.Request) {
infos := make(map[string]interface{})
infos["Version"] = util.VERSION
args := struct {
Version string
Topology interface{}
Leader string
Peers interface{}
Stats map[string]interface{}
Counters *stats.ServerStats
Version string
Topology interface{}
RaftServer raft.Server
Stats map[string]interface{}
Counters *stats.ServerStats
}{
util.VERSION,
ms.Topo.ToMap(),
ms.Topo.RaftServer.Leader(),
ms.Topo.RaftServer.Peers(),
ms.Topo.RaftServer,
infos,
serverStats,
}

View file

@ -33,6 +33,7 @@ var StatusTpl = template.Must(template.New("status").Parse(`<!DOCTYPE html>
<th>Max</th>
<td>{{ .Topology.Max }}</td>
</tr>
{{ with .RaftServer }}
<tr>
<th>Leader</th>
<td><a href="http://{{ .Leader }}">{{ .Leader }}</a></td>
@ -45,6 +46,7 @@ var StatusTpl = template.Must(template.New("status").Parse(`<!DOCTYPE html>
{{ end }}
</ul></td>
</tr>
{{ end }}
</tbody>
</table>
</div>