Documentation ¶
Overview ¶
Package spoterm provides advance notification of EC2 spot instance termination, allowing an instance to clean up state before termination.
For documentation of spot termination, see http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-interruptions.html
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SpotermNotify ¶
SpotermNotify returns a channel of time.Time or an error. When the spot termination-time is set in instance metadata, the time is sent on the channel. If an unrecoverable error occurs after initialization, the channel is closed. The termination-time is polled every 5 seconds, giving a minimum of 115 seconds from notification to termination. See http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-interruptions.html
Example ¶
ch, err := SpotermNotify() if err != nil { // handle error // an error will occur if run on a non-ec2 instance log.Fatal(err) } go func() { if t, ok := <-ch; ok { // received termination-time // run cleanup actions here log.Printf("the instance will be terminated at %v", t) } else { log.Printf("SpotermNotify channel closed due to error") } }()
Output:
Types ¶
This section is empty.