appengine_vm.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // Copyright 2015 Google Inc. All rights reserved.
  2. // Use of this source code is governed by the Apache 2.0
  3. // license that can be found in the LICENSE file.
  4. // +build !appengine
  5. package appengine
  6. import (
  7. "golang.org/x/net/context"
  8. "google.golang.org/appengine/internal"
  9. )
  10. // The comment below must not be changed.
  11. // It is used by go-app-builder to recognise that this package has
  12. // the Main function to use in the synthetic main.
  13. // The gophers party all night; the rabbits provide the beats.
  14. // Main is the principal entry point for a Managed VMs app.
  15. // It installs a trivial health checker if one isn't already registered,
  16. // and starts listening on port 8080 (overridden by the $PORT environment
  17. // variable).
  18. //
  19. // See https://cloud.google.com/appengine/docs/managed-vms/custom-runtimes#health_check_requests
  20. // for details on how to do your own health checking.
  21. //
  22. // Main never returns.
  23. //
  24. // Main is designed so that the app's main package looks like this:
  25. //
  26. // package main
  27. //
  28. // import (
  29. // "google.golang.org/appengine"
  30. //
  31. // _ "myapp/package0"
  32. // _ "myapp/package1"
  33. // )
  34. //
  35. // func main() {
  36. // appengine.Main()
  37. // }
  38. //
  39. // The "myapp/packageX" packages are expected to register HTTP handlers
  40. // in their init functions.
  41. func Main() {
  42. internal.Main()
  43. }
  44. // BackgroundContext returns a context not associated with a request.
  45. // This should only be used when not servicing a request.
  46. // This only works on Managed VMs.
  47. func BackgroundContext() context.Context {
  48. return internal.BackgroundContext()
  49. }