简体   繁体   中英

How do I tell my Elastic Beanstalk instance not to go to sleep?

I've setup an Elastic Beanstalk instance on the .NET (Windows/IIS) platform. I've deployed a .NET Core application there that does 2 things:

  1. Respond with Hello world! when I hit the end point - but I don't care about that.
  2. Sets up a listener for RabbitMQ (also hosted in AWS). This listener fires off an SMS every time I drop some a message in RabbitMQ.

Item 2 works great - I drop off a message and less than a second later I get an SMS message on my phone.

The problem is that AWS puts the application to sleep after a period of inactivity. And that causes the RabbitMQ listener to also go to sleep. This results in undelivered SMS messages. Until I wake up the instance by going to the URL assigned to my by Elastic Beanstalk.

How do I make my Elastic Beanstalk instance not go to sleep? Is there something I can call from C# code to prevent it from doing so?

Here is what I implemented following this article .

  1. Create a .ebextensions folder at the root of your api/web project.
  2. In this project, any .config file will be used as config for your elastic beanstalk, they will be applied in alphabetical order. So create a file containing the following : (see in the link, the white space is important and I can't seem to get it right here...)

    commands: setIdleTimeoutToZero: cwd: "C:\\windows\\system32\\inetsrv" command: "appcmd set apppool /apppool.name:DefaultAppPool /.processModel.idleTimeout:0.00:00:00"

  3. Make sure the file is always copied to output.

  4. You should be good to go.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM