Skip to content

Commit

Permalink
Merge pull request #272 from ably-forks/feature/expose-listen-port
Browse files Browse the repository at this point in the history
Expose server listen port
  • Loading branch information
tylertreat authored Oct 8, 2020
2 parents 71318fb + 9605965 commit 6d2e262
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,19 @@ func (s *Server) IsRunning() bool {
return s.running
}

// GetListenPort returns the port the server is listening to. Returns 0 if the
// server is not listening.
func (s *Server) GetListenPort() int {
s.mu.RLock()
defer s.mu.RUnlock()

if s.listener == nil {
return 0
}

return s.listener.Addr().(*net.TCPAddr).Port
}

// recoverAndPersistState recovers any existing server metadata state from disk
// to initialize the server then writes the metadata back to disk.
func (s *Server) recoverAndPersistState() error {
Expand Down

0 comments on commit 6d2e262

Please sign in to comment.