add reloading and stopping from tsctl
This commit is contained in:
@@ -94,17 +94,17 @@ type LiveServer struct {
|
||||
handler http.Handler
|
||||
|
||||
active atomic.Value // *instance
|
||||
mu sync.Mutex
|
||||
mu sync.Mutex
|
||||
|
||||
statusMu sync.Mutex
|
||||
status Status
|
||||
status Status
|
||||
|
||||
initDone bool
|
||||
}
|
||||
|
||||
type instance struct {
|
||||
srv *http.Server
|
||||
ln net.Listener
|
||||
ln net.Listener
|
||||
|
||||
addr string
|
||||
}
|
||||
@@ -198,10 +198,10 @@ func (ls *LiveServer) Start(addr string) error {
|
||||
return err
|
||||
}
|
||||
srv := &http.Server{Handler: ls.handler}
|
||||
|
||||
|
||||
ls.active.Store(&instance{
|
||||
srv: srv,
|
||||
ln: ln,
|
||||
srv: srv,
|
||||
ln: ln,
|
||||
addr: addr,
|
||||
})
|
||||
|
||||
@@ -249,7 +249,6 @@ func (ls *LiveServer) Stop() error {
|
||||
return ls.stop(inst)
|
||||
}
|
||||
|
||||
|
||||
func (ls *LiveServer) Reload(newAddr string) error {
|
||||
ls.mu.Lock()
|
||||
oldInstAny := ls.active.Load()
|
||||
@@ -258,7 +257,7 @@ func (ls *LiveServer) Reload(newAddr string) error {
|
||||
oldAddr = oldInstAny.(*instance).addr
|
||||
}
|
||||
ls.mu.Unlock()
|
||||
|
||||
|
||||
if oldAddr == newAddr {
|
||||
return nil
|
||||
}
|
||||
@@ -447,7 +446,6 @@ func (ls *LiveServer) Reload(newAddr string) error {
|
||||
// // }
|
||||
|
||||
// ls.setStatus(Status{ID: StatusStarting})
|
||||
|
||||
|
||||
// err := ls.Start()
|
||||
// if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user