mirror of
https://github.com/Caraxi/mare.server.git
synced 2025-12-12 19:47:21 +01:00
allow servers to read appsettings from different location
This commit is contained in:
parent
561e48510b
commit
475892dd46
5 changed files with 72 additions and 0 deletions
|
|
@ -0,0 +1,13 @@
|
||||||
|
{
|
||||||
|
"version": 1,
|
||||||
|
"isRoot": true,
|
||||||
|
"tools": {
|
||||||
|
"dotnet-ef": {
|
||||||
|
"version": "8.0.10",
|
||||||
|
"commands": [
|
||||||
|
"dotnet-ef"
|
||||||
|
],
|
||||||
|
"rollForward": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -27,6 +27,20 @@ public class Program
|
||||||
return Host.CreateDefaultBuilder(args)
|
return Host.CreateDefaultBuilder(args)
|
||||||
.UseSystemd()
|
.UseSystemd()
|
||||||
.UseConsoleLifetime()
|
.UseConsoleLifetime()
|
||||||
|
.ConfigureAppConfiguration((ctx, config) =>
|
||||||
|
{
|
||||||
|
var appSettingsPath = Environment.GetEnvironmentVariable("APPSETTINGS_PATH");
|
||||||
|
if (!string.IsNullOrEmpty(appSettingsPath))
|
||||||
|
{
|
||||||
|
config.AddJsonFile(appSettingsPath, optional: true, reloadOnChange: true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
config.AddEnvironmentVariables();
|
||||||
|
})
|
||||||
.ConfigureWebHostDefaults(webBuilder =>
|
.ConfigureWebHostDefaults(webBuilder =>
|
||||||
{
|
{
|
||||||
webBuilder.UseContentRoot(AppContext.BaseDirectory);
|
webBuilder.UseContentRoot(AppContext.BaseDirectory);
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,20 @@ public class Program
|
||||||
return Host.CreateDefaultBuilder(args)
|
return Host.CreateDefaultBuilder(args)
|
||||||
.UseSystemd()
|
.UseSystemd()
|
||||||
.UseConsoleLifetime()
|
.UseConsoleLifetime()
|
||||||
|
.ConfigureAppConfiguration((ctx, config) =>
|
||||||
|
{
|
||||||
|
var appSettingsPath = Environment.GetEnvironmentVariable("APPSETTINGS_PATH");
|
||||||
|
if (!string.IsNullOrEmpty(appSettingsPath))
|
||||||
|
{
|
||||||
|
config.AddJsonFile(appSettingsPath, optional: true, reloadOnChange: true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
config.AddEnvironmentVariables();
|
||||||
|
})
|
||||||
.ConfigureWebHostDefaults(webBuilder =>
|
.ConfigureWebHostDefaults(webBuilder =>
|
||||||
{
|
{
|
||||||
webBuilder.UseContentRoot(AppContext.BaseDirectory);
|
webBuilder.UseContentRoot(AppContext.BaseDirectory);
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,20 @@ public class Program
|
||||||
Host.CreateDefaultBuilder(args)
|
Host.CreateDefaultBuilder(args)
|
||||||
.UseSystemd()
|
.UseSystemd()
|
||||||
.UseConsoleLifetime()
|
.UseConsoleLifetime()
|
||||||
|
.ConfigureAppConfiguration((ctx, config) =>
|
||||||
|
{
|
||||||
|
var appSettingsPath = Environment.GetEnvironmentVariable("APPSETTINGS_PATH");
|
||||||
|
if (!string.IsNullOrEmpty(appSettingsPath))
|
||||||
|
{
|
||||||
|
config.AddJsonFile(appSettingsPath, optional: true, reloadOnChange: true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
config.AddEnvironmentVariables();
|
||||||
|
})
|
||||||
.ConfigureWebHostDefaults(webBuilder =>
|
.ConfigureWebHostDefaults(webBuilder =>
|
||||||
{
|
{
|
||||||
webBuilder.UseContentRoot(AppContext.BaseDirectory);
|
webBuilder.UseContentRoot(AppContext.BaseDirectory);
|
||||||
|
|
@ -39,6 +53,9 @@ public class Program
|
||||||
builder.AddConfiguration(ctx.Configuration.GetSection("Logging"));
|
builder.AddConfiguration(ctx.Configuration.GetSection("Logging"));
|
||||||
builder.AddFile(o => o.RootPath = AppContext.BaseDirectory);
|
builder.AddFile(o => o.RootPath = AppContext.BaseDirectory);
|
||||||
});
|
});
|
||||||
|
webBuilder.ConfigureKestrel((opt) =>
|
||||||
|
{
|
||||||
|
});
|
||||||
webBuilder.UseStartup<Startup>();
|
webBuilder.UseStartup<Startup>();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -35,6 +35,20 @@ public class Program
|
||||||
return Host.CreateDefaultBuilder(args)
|
return Host.CreateDefaultBuilder(args)
|
||||||
.UseSystemd()
|
.UseSystemd()
|
||||||
.UseConsoleLifetime()
|
.UseConsoleLifetime()
|
||||||
|
.ConfigureAppConfiguration((ctx, config) =>
|
||||||
|
{
|
||||||
|
var appSettingsPath = Environment.GetEnvironmentVariable("APPSETTINGS_PATH");
|
||||||
|
if (!string.IsNullOrEmpty(appSettingsPath))
|
||||||
|
{
|
||||||
|
config.AddJsonFile(appSettingsPath, optional: true, reloadOnChange: true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
|
||||||
|
}
|
||||||
|
|
||||||
|
config.AddEnvironmentVariables();
|
||||||
|
})
|
||||||
.ConfigureWebHostDefaults(webBuilder =>
|
.ConfigureWebHostDefaults(webBuilder =>
|
||||||
{
|
{
|
||||||
webBuilder.UseContentRoot(AppContext.BaseDirectory);
|
webBuilder.UseContentRoot(AppContext.BaseDirectory);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue