-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathProgram.cs
36 lines (29 loc) · 1.17 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using FormCMS.Course;
using Microsoft.Extensions.Configuration;
var builder = DistributedApplication.CreateBuilder(args);
var redis = builder.AddRedis(name:Constants.Redis);
var (isTesting, useSqlServer) = (builder.Configuration.GetValue("IsTesting", false), builder.Configuration.GetValue("UseSqlServer", false));
var databaseProvider = useSqlServer ? Constants.SqlServer : Constants.Postgres;
IResourceBuilder<IResourceWithConnectionString> db = useSqlServer
? builder.AddSqlServer(Constants.SqlServer)
: builder.AddPostgres(Constants.Postgres);
if (isTesting) return RunAsTwoSeparateApps();
builder.AddProject<Projects.FormCMS_Course>(name: "web")
.WithEnvironment(Constants.DatabaseProvider, databaseProvider)
.WithReference(redis)
.WithReference(db)
.WithReplicas(2);
builder.Build().Run();
return 0;
int RunAsTwoSeparateApps()
{
for (var i = 0; i < 2; i++)
{
builder.AddProject<Projects.FormCMS_Course>(name: "web" + i, launchProfileName: "http" + i)
.WithEnvironment(Constants.DatabaseProvider, databaseProvider)
.WithReference(redis)
.WithReference(db);
}
builder.Build().Run();
return 0;
}