Following an article that described how to create a windows service from a .NET core application (or actually any other binary): https://alexrait.blogspot.com/2021/07/how-to-create-service-in-windows.html, we would like to do the same on a Linux machine
On Linux we use systemctl and the .service file that describes the service
This article: https://swimburger.net/blog/dotnet/how-to-run-a-dotnet-core-console-app-as-a-service-using-systemd-on-linux descibes well how to do the setup.
For .NET, an additional option is useful: WorkingFolder=/some/path, since some of the path references in the app might be relative.
Some useful commands:
- systemctl enable ServiceName
- systemctl daemon-reload
- systemctl start ServiceName
- systemctl status ServiceName
- journalctl -u ServiceName -f