gerhalt / mining-camp

Easy automated configuration and deployment of Minecraft servers on AWS spot instances, featuring automatic backups and restoration using S3.
45 stars 7 forks source link

Graceful shutdown on ASG scale-in #20

Open gerhalt opened 4 years ago

gerhalt commented 4 years ago

Spot instance termination is very frequently checked via a cron job running on the host, and if a termination notice is seen, the server is gracefully stopped and a backup produced to S3 (see utilities/shutdown.sh).

This doesn't happen if the ASG is scaled in. Instead, we could register a lifecycle hook with a consumer listening to an SQS topic. Because our ASGs only operate with a singleton, having a topic per ASG and a consumer on the box, ready to call the shutdown script, seems reasonable.

This feature sets the stage for setting up things like user-count-based health checks, where the ASG could autoscale down to 0 if no players have been present for a certain amount of time.