mirror of
https://github.com/m1k1o/neko-rooms.git
synced 2026-11-02 22:51:34 -06:00
add stop timeout to config.
This commit is contained in:
@@ -32,6 +32,7 @@ type Room struct {
|
|||||||
PathPrefix string
|
PathPrefix string
|
||||||
Labels []string
|
Labels []string
|
||||||
WaitEnabled bool
|
WaitEnabled bool
|
||||||
|
StopTimeoutSec int
|
||||||
|
|
||||||
StorageEnabled bool
|
StorageEnabled bool
|
||||||
StorageInternal string
|
StorageInternal string
|
||||||
@@ -100,6 +101,11 @@ func (Room) Init(cmd *cobra.Command) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmd.PersistentFlags().Int("stop_timeout", 10, "timeout in seconds for stopping the room with SIGTERM, after that SIGKILL is used (0 to disable, -1 to wait forever)")
|
||||||
|
if err := viper.BindPFlag("stop_timeout", cmd.PersistentFlags().Lookup("stop_timeout")); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
// Data
|
// Data
|
||||||
|
|
||||||
cmd.PersistentFlags().Bool("storage.enabled", true, "whether storage is enabled, where peristent containers data will be stored")
|
cmd.PersistentFlags().Bool("storage.enabled", true, "whether storage is enabled, where peristent containers data will be stored")
|
||||||
@@ -207,6 +213,7 @@ func (s *Room) Set() {
|
|||||||
s.PathPrefix = path.Join("/", path.Clean(viper.GetString("path_prefix")))
|
s.PathPrefix = path.Join("/", path.Clean(viper.GetString("path_prefix")))
|
||||||
s.Labels = viper.GetStringSlice("labels")
|
s.Labels = viper.GetStringSlice("labels")
|
||||||
s.WaitEnabled = viper.GetBool("wait_enabled")
|
s.WaitEnabled = viper.GetBool("wait_enabled")
|
||||||
|
s.StopTimeoutSec = viper.GetInt("stop_timeout")
|
||||||
|
|
||||||
s.StorageEnabled = viper.GetBool("storage.enabled")
|
s.StorageEnabled = viper.GetBool("storage.enabled")
|
||||||
s.StorageInternal = viper.GetString("storage.internal")
|
s.StorageInternal = viper.GetString("storage.internal")
|
||||||
|
|||||||
@@ -724,7 +724,10 @@ func (manager *RoomManagerCtx) Remove(ctx context.Context, id string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Stop the actual container
|
// Stop the actual container
|
||||||
err = manager.client.ContainerStop(ctx, id, container.StopOptions{})
|
err = manager.client.ContainerStop(ctx, id, container.StopOptions{
|
||||||
|
Signal: "SIGTERM",
|
||||||
|
Timeout: &manager.config.StopTimeoutSec,
|
||||||
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@@ -998,7 +1001,10 @@ func (manager *RoomManagerCtx) Stop(ctx context.Context, id string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Stop the actual container
|
// Stop the actual container
|
||||||
return manager.client.ContainerStop(ctx, id, container.StopOptions{})
|
return manager.client.ContainerStop(ctx, id, container.StopOptions{
|
||||||
|
Signal: "SIGTERM",
|
||||||
|
Timeout: &manager.config.StopTimeoutSec,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (manager *RoomManagerCtx) Restart(ctx context.Context, id string) error {
|
func (manager *RoomManagerCtx) Restart(ctx context.Context, id string) error {
|
||||||
@@ -1008,7 +1014,10 @@ func (manager *RoomManagerCtx) Restart(ctx context.Context, id string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Restart the actual container
|
// Restart the actual container
|
||||||
return manager.client.ContainerRestart(ctx, id, container.StopOptions{})
|
return manager.client.ContainerRestart(ctx, id, container.StopOptions{
|
||||||
|
Signal: "SIGTERM",
|
||||||
|
Timeout: &manager.config.StopTimeoutSec,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// events
|
// events
|
||||||
|
|||||||
Reference in New Issue
Block a user