Skip to content

Commit

Permalink
Revert "cold start optimization"
Browse files Browse the repository at this point in the history
This reverts commit 30e9430.
  • Loading branch information
dopoto committed Sep 14, 2024
1 parent 30e9430 commit 29c290a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 11 deletions.
39 changes: 34 additions & 5 deletions Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,42 @@
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddUserSecrets<EnvironmentSpecificSettings>(optional: true)
.AddEnvironmentVariables();

// Add services to the container.

builder.Services.AddSignalR();
builder.Services.AddMemoryCache();
//builder.Services.AddCors();
//builder.Services.AddControllers();
//// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
//builder.Services.AddEndpointsApiExplorer();
//builder.Services.AddSwaggerGen();

builder.Services.Add(ServiceDescriptor.Singleton<IMemoryCache, MemoryCache>());
builder.Services.AddSingleton<GroupService>();

var app = builder.Build();

// Preload SignalR hubs by making a dummy connection during startup
var hubContext = app.Services.GetService<IHubContext<BeepHub>>();
await hubContext.Clients.All.SendAsync("preload");
// Configure the HTTP request pipeline.
//if (app.Environment.IsDevelopment())
//{
// app.UseSwagger();
// app.UseSwaggerUI();
//}

//app.UseHttpsRedirection();

//app.UseAuthorization();

//app.MapControllers();

//app.Run();

//app.UseCors(builder =>
//{
// builder.WithOrigins(origins: environmentSettings.AllowedCorsOrigins ?? []);
// builder.AllowAnyHeader();
// builder.AllowAnyMethod();
//});

app.UseHttpsRedirection();
app.UseRouting();
Expand All @@ -32,10 +59,11 @@
(HttpContext context, GroupService groupService) =>
groupService.GetConnectionsByGroup(context.Request.Query["groupName"])

Check warning on line 60 in Program.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'groupName' in 'List<string> GroupService.GetConnectionsByGroup(string groupName)'.

Check warning on line 60 in Program.cs

View workflow job for this annotation

GitHub Actions / build

Possible null reference argument for parameter 'groupName' in 'List<string> GroupService.GetConnectionsByGroup(string groupName)'.
);
app.MapGet("/healthcheck", () => "1");


app.Run();


public class BeepHub : Hub
{
private readonly GroupService _groupService;
Expand All @@ -45,6 +73,7 @@ public BeepHub(GroupService groupService)
_groupService = groupService;
}


public async Task Play(string freqInKhz, string durationInSeconds, string groupName)
{
Console.WriteLine("Play - freqInKhz=" + freqInKhz + ", durationInSeconds:" + durationInSeconds + ", group:" + groupName);
Expand Down
6 changes: 0 additions & 6 deletions remote-beep-backend.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@
<RootNamespace></RootNamespace>
</PropertyGroup>

<PropertyGroup>
<PublishTrimmed>true</PublishTrimmed>
<PublishReadyToRun>true</PublishReadyToRun>
<TieredCompilation>true</TieredCompilation>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
</ItemGroup>
Expand Down

0 comments on commit 29c290a

Please sign in to comment.