main.go 506 B

1234567891011121314151617181920212223242526272829303132333435
  1. package main
  2. import (
  3. "os"
  4. "os/signal"
  5. "net/http"
  6. _ "net/http/pprof"
  7. )
  8. const version = "2.1.5"
  9. type ctxKey string
  10. func main() {
  11. if len(os.Getenv("IMGPROXY_PPROF_BIND")) > 0 {
  12. go func() {
  13. http.ListenAndServe(os.Getenv("IMGPROXY_PPROF_BIND"), nil)
  14. }()
  15. }
  16. if len(os.Getenv("_LAMBDA_SERVER_PORT")) == 0 {
  17. s := startServer()
  18. stop := make(chan os.Signal, 1)
  19. signal.Notify(stop, os.Interrupt, os.Kill)
  20. <-stop
  21. shutdownServer(s)
  22. shutdownVips()
  23. } else {
  24. startLambdaServer()
  25. }
  26. }