Search code examples
iis-7.5octopus-deployhangfire

How to get IIS site to start up automatically after deployment?


I have a Web API service that I'm deploying to my various environments (using Octopus Deploy). It is supposed to do various tasks on startup, e.g. run any migration scripts required by Entity Framework Code First, and some background tasks managed by Hangfire. Trouble is, the web site only wakes up the first time someone makes a call to it. I want it to run as soon as I've deployed it. I could do it manually just by pointing a web browser at the API's home page, but that requires me to remember to do that, and if I'm deploying to multiple tentacles, that's a major PITA.

How can I force the web site to start up automatically, right after it's been deployed?


Solution

  • In the control panel under turn windows features on or off, Under "Web Server (IIS) | Web Server | Application Development", select "Application Initialization".

    In IIS, on the advanced settings for the Application Pool, "Start Mode" should be set to "AlwaysRunning".

    In IIS, on the advanced settings for the site, "Preload Enabled" should be set to "true".

    A new deployment will cause it to start again (possibly after a short delay).