I have a C# DotNet 5 worker which connects to a database and do various stuff.
If I deploy the app in a AlmaLinux x64 environment and execute it as normal application, it works everything.
When I try to execute as Systemd service I have the following error
unhandled exception. System.ArgumentNullException: Value cannot be null. (Parameter 'connectionString')
This is my appsettings.json
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Warning"
}
},
"ConnectionStrings": {
"connectionString": "Server=192.168.0.191;Database=new_centrex_db;Password=[REDACTED];UID=[REDACTED]"
},
"apiconfig": {
"apiUrl": "https://example.org/theApi",
"authHeaderName": "X-authenticate"
}
}
this is the unit file:
[Unit]
Description=Test
[Service]
Type=simple
ExecStart=/home/utente/publish/CentrexNotificatorD
User=utente
Group=utente
[Install]
WantedBy=multi-user.target
I tried with and without User and Group and Type with simple and notify, with no luck.
The permissions are ugo+rw
for all the files, and ugo+rx
for the executable.
Of course I'm using .UseSystemd()
inside the program.
What am I doing wrong?
Found the problem: I had to put a WorkingDirectory
in the .service file pointing the directory where the service is. In this case /home/utente/publish