timeout.go 600 B

1234567891011121314151617181920212223242526
  1. package timeout
  2. import (
  3. "os"
  4. "strconv"
  5. "time"
  6. )
  7. // Duration is the default time to wait for various operations.
  8. // - Waiting for async notifications from HCS
  9. // - Waiting for processes to launch through
  10. // - Waiting to copy data to/from a launched processes stdio pipes.
  11. //
  12. // This can be overridden through environment variable `HCS_TIMEOUT_SECONDS`
  13. var Duration = 4 * time.Minute
  14. func init() {
  15. envTimeout := os.Getenv("HCSSHIM_TIMEOUT_SECONDS")
  16. if len(envTimeout) > 0 {
  17. e, err := strconv.Atoi(envTimeout)
  18. if err == nil && e > 0 {
  19. Duration = time.Second * time.Duration(e)
  20. }
  21. }
  22. }