mirror of
https://github.com/zix99/traefik-lazyload.git
synced 2025-12-21 13:23:04 +01:00
Stop all containers
This commit is contained in:
4
main.go
4
main.go
@@ -38,6 +38,10 @@ func main() {
|
|||||||
}
|
}
|
||||||
defer core.Close()
|
defer core.Close()
|
||||||
|
|
||||||
|
if config.Model.StopAtBoot {
|
||||||
|
core.StopAll()
|
||||||
|
}
|
||||||
|
|
||||||
// Set up http server
|
// Set up http server
|
||||||
subFs, _ := fs.Sub(httpAssets, "assets")
|
subFs, _ := fs.Sub(httpAssets, "assets")
|
||||||
http.Handle(httpAssetPrefix, http.StripPrefix(httpAssetPrefix, http.FileServer(http.FS(subFs))))
|
http.Handle(httpAssetPrefix, http.StripPrefix(httpAssetPrefix, http.FileServer(http.FS(subFs))))
|
||||||
|
|||||||
@@ -94,6 +94,20 @@ func (s *Core) StartHost(hostname string) (*StartResult, error) {
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Core) StopAll() {
|
||||||
|
s.mux.Lock()
|
||||||
|
defer s.mux.Unlock()
|
||||||
|
|
||||||
|
ctx := context.Background()
|
||||||
|
|
||||||
|
logrus.Info("Stopping all containers...")
|
||||||
|
for cid, ct := range s.active {
|
||||||
|
logrus.Infof("Stopping %s...", ct.name)
|
||||||
|
s.client.ContainerStop(ctx, cid, container.StopOptions{})
|
||||||
|
delete(s.active, cid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Core) startContainer(ctx context.Context, ct *types.Container) {
|
func (s *Core) startContainer(ctx context.Context, ct *types.Container) {
|
||||||
s.mux.Lock()
|
s.mux.Lock()
|
||||||
defer s.mux.Unlock()
|
defer s.mux.Unlock()
|
||||||
|
|||||||
Reference in New Issue
Block a user