some changes
This commit is contained in:
@@ -114,7 +114,12 @@ func Create(name string) (*LiveServer, error) {
|
||||
return nil, fmt.Errorf("server name is empty")
|
||||
}
|
||||
|
||||
if isExists(name) {
|
||||
return nil, fmt.Errorf("server with this name is already exists")
|
||||
}
|
||||
|
||||
ls := &LiveServer{name: name}
|
||||
pushLs(ls)
|
||||
ls.setStatus(Status{ID: StatusStopped})
|
||||
return ls, nil
|
||||
}
|
||||
@@ -241,6 +246,17 @@ func (ls *LiveServer) stop(inst *instance) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func StopAll() (errors []error) {
|
||||
for key, ls := range reg.lss {
|
||||
slog.Debug("stopping LiveServer", slog.String("name", key))
|
||||
err := ls.Stop()
|
||||
if err != nil {
|
||||
errors = append(errors, err)
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (ls *LiveServer) Stop() error {
|
||||
inst := ls.active.Load().(*instance)
|
||||
if inst == nil {
|
||||
@@ -280,6 +296,12 @@ func (ls *LiveServer) Reload(newAddr string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Close deletes [LiveServer] object from registry, and sets ls to nil
|
||||
func (ls *LiveServer) Close() {
|
||||
deleteLs(ls.name)
|
||||
ls = nil
|
||||
}
|
||||
|
||||
// package server
|
||||
|
||||
// import (
|
||||
|
||||
Reference in New Issue
Block a user