Environment: ASP.NET Core 2.1, Ubuntu.
In old style ASP.NET, when I did a bin deploy (uploaded some dll files for example), the webapp would detect that and reload itself - very useful.
With Core it doesn't do that. I need to stop and restart the dotnet MyApp.dll
process.
How do I make it detect changes to binaries and reload?
There are file watchers in Ubuntu that can issue restart commands whenever files are changed like systemd
or inotify
, but I would strongly advise against that. Uploads can pause or be slow and when uploading 50 files imagine restart after every single one every couple seconds. Server has no way to know when you have finished uploading last DLL. IIS has same problem, it's reliable in development because you refresh the page after the full DLL rebuild. But when in production you don't want random visitors to boot your site midway while it's still uploading. Errors, file locks, all kinds of weirds things can happen.
As pointed by Chris Pratt you want to script your deployment workflow. Idk what environment you are developing on, but if you have Visual Studio and WinSCP it's as easy as writing couple lines of code with Scripting and Task Automation.
Then your publish workflow can be for example as following:
systemctl restart kestrel-myapp
commandThere's nothing I'm aware of that will do this for you. IIS watches things like the bin
directory, web.config, etc. and recycles the App Pool when it detects changes, but that's because it knows to. It's also a full-featured web server, and App Pool recycling on file changes is one of those features. Kestrel, which I assume your using is not. It's a very simple web server that does just what it needs to do as strictly a web server. That's why a more traditional web server like IIS, Apache, Nginx, etc. is normally used as a reverse proxy in front of Kestrel - to provide more advanced functionalities.
All that said, though, this is really just a matter of your release strategy. Personally, I'd encourage you to go with something far more robust that copy-pasting DLLs, but if you want to go that route, you can also script it. Create a shell script to copy the bin
directory and restart your app. Your release should be one rails as much as possible. Every time human intervention is called for, you have a potential point of failure, because humans are inherently fallible. A script, however, once tested and ensured to work, will pretty much work every time, because it always does the same things in the same order.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With