Issue:
I am running a .net core application on a Raspberry PI. I am loading the configuration from a JSON file and storing in a class for reference in the application - a hosted service in this case. If I start the application manually and then update the config file, the changes are reflected in the application. If however I set the application to launch automatically on boot and then modify the config file, the application does not use the updated config.
I have tried launching the application via an entry in rc.local and as a service using systemd. Again while the application launches and runs with either method, it does not pick up config changes.
System Details:
- .Net Core 2.1
- OS Build: Raspbian 4.14.52-v7+ #1123
Startup.cs
public void ConfigureServices(IServiceCollection services)
{
// Register Hosted Services
services.AddOptions();
services.AddSingleton<IHostedService, MonitorService>();
services.Configure<AppSettings (Configuration.GetSection("AppSettings"));
services.AddMvc();
}
Service Constructor
public MonitorService(IOptionsMonitor appSettings) {
this.AppSettings = appSettings;
}
rc.local
#!/bin/sh -e
sudo /home/pi/App/MonitorApp &
exit 0
MonitorApp.service
[Unit]
Description=My Sample Service
After=multi-user.target
[Service]
Type=idle
ExecStart=/home/pi/App/MonitorApp
User=pi
[Install]
WantedBy=multi-user.target
MonitorApp.serviceis the right way and looks good except Type=idle. But it seems it does not fit the environment. Where is the config file exactly (path) located? – Ingo Oct 25 '18 at 19:38