This is more or less the same for Go and the like where the binary(“exe”) can listen to on a given port. That and I want to thank Sutean for his post similar to well this one; however, I wanted to dig in a little further into the application pool explanation and provide some additional insight for those that only have to setup IIS every blue moon having my own documented. Further I’m going to be extremely basic so something that seems straight forward will be included. I also used Actix web for my server, but again this could be any framework where the executable can listen on a port.
Let’s create Rust App:
Then “cargo build — release”
Yes, there are several ways to make something basic I have more complex examples of app config if you have questions feel free to ask. Also be careful with debug logs as I’ve included above this can eat up space quick. So we have our exe let’s move on to the server.
So on the server I copied my little executable from our release build above to a folder in the directory pictured below. We will go into the web.config file below but for now this could just be an empty web.config file.
For the server setup we first thing we need is the ASP.net core hosting addon found here. Once that is installed then we can configure the web.config file for our needs. Before we do this know the ways of the past have changed from using url rewrite to httpplatformhandler, and now currently asp.net core hosting. The later comes with two variants of hosting models. In and out of process just know that out of process comes with some overhead. You can read about the differences in detail here. Also all the configuration params can seen here though you need to scroll to the “Attributes of the aspNetCore element”.
Let’s get started first create the site:
So the physical path is where we saved the binary and config file. Next make the changes to the file as such
Alright now let’s look at the application pool advanced settings
I wanted to make mention of a few areas and point out some things.
First in order for the app to actually work we need to change the .net CLR version to “no managed code”.
If you are processing your requests pretty heavily you might encounter several 503 errors you can raise that via the queue length.
The start mode doesn’t really matter in our simple case but if you are caching data on the server you prob want it always running.
The maximum number of workers is a grey area. Actix will use the max amount of workers available. I would assume if the code is unmanaged this setting would have no effect and actix would use the max available if anyone can comment on this I’d appreciate the clarity.
Look over your recycle settings to fit your needs.
Alright, well everything is setup and configured by this point because we should have grabbed the port from the environment var so we should be able to just browse localhost/test and see our string.
Huzzah! Yes, it’s IE :( but it’s a simple dev box
We added logging though let’s check where that is.
Update the path to the local site folder then we can makes several requests.
This indeed makes the format we set. While in development there isn’t a need to include the new line but I’d recommend adding it in the format of the middleware we added.
Aside, if you fire up your server and think everything is configured and get status code 500 with no errors or logs (provided you are logging) chances are your web.config has a typo or things like the param being case sensitive. You can verify this by clicking on the config and ensure that it opens.