fix(server.go) use setState in function init to avoid data race.