Restarting a container on ECS

I needed to restart a docker container on ECS periodically. It seems like people are setting up cron jobs to do this but there’s an easier way. All you have to do is exit the process and it’ll automatically get restarted. In python this is as simple as sys.exit(0)

My Tornado web server code to do this every 15 minutes looks like this:

1
    tornado.ioloop.PeriodicCallback(lambda: sys.exit(0), 1000 * 60 * 15).start()