Skip to content

Commit

Permalink
Merge pull request #23 from Team-Wilhelm/deployed
Browse files Browse the repository at this point in the history
Deployed
  • Loading branch information
juuwel authored May 27, 2024
2 parents 4684690 + d0eb7df commit f271cb2
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 11 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy-be.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
heroku_app_name: ${{ secrets.HEROKU_APP_NAME }}
heroku_email: ${{ secrets.HEROKU_EMAIL }}
usedocker: false
branch: deployed

env: #only the key names below should be prefixed HD_ and the ${{secrets.NAME}} should not
HD_DbConnection: ${{secrets.DbConnection}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace Core.Services.External;
namespace Core.Services.External.BackgroundRemoval;

public interface IImageBackgroundRemoverService
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using Core.Services.External.BackgroundRemoval;

namespace Core.Services.External;

public class MockImageBackgroundRemoverService : IImageBackgroundRemoverService
Expand Down
2 changes: 0 additions & 2 deletions Core/Services/MqttSubscriberService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,5 @@ public async Task SubscribeAsync()
.Build();

await mqttClient.SubscribeAsync(mqttSubscribeOptions, CancellationToken.None);

Console.ReadLine();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using api.Extensions;
using Core.Services.External;
using Core.Services.External.BackgroundRemoval;
using Fleck;
using lib;
using Shared.Exceptions;
Expand Down
13 changes: 5 additions & 8 deletions api/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public static async Task<WebApplication> StartApi(string[] args)
.Build();

await dbContainer.StartAsync();
var connectionString = dbContainer.GetConnectionString() + ";Include Error Detail=true;";

var connectionString = dbContainer.GetConnectionString();
builder.Services.AddDbContextFactory<ApplicationDbContext>(options =>
{
options.UseNpgsql(connectionString ?? throw new Exception("Connection string cannot be null"));
Expand All @@ -62,7 +62,7 @@ public static async Task<WebApplication> StartApi(string[] args)
var connectionString = builder.Configuration.GetConnectionString("BotaniqueDb");
builder.Services.AddDbContextFactory<ApplicationDbContext>(options =>
{
connectionString ??= Environment.GetEnvironmentVariable("BotaniqueDb");
connectionString ??= Environment.GetEnvironmentVariable("DbConnection");
options.UseNpgsql(connectionString ?? throw new Exception("Connection string cannot be null"));
});
}
Expand Down Expand Up @@ -111,9 +111,10 @@ public static async Task<WebApplication> StartApi(string[] args)
await db.SeedDevelopmentDataAsync(scope, app.Configuration["AzureBlob:DefaultPlantImageUrl"] ?? "https://example.com");
}

builder.WebHost.UseUrls("http://*:9999");

var port = Environment.GetEnvironmentVariable("PORT") ?? "8181";
var wsServer = new WebSocketServer($"ws://0.0.0.0:{port}");
builder.WebHost.UseUrls("http://*:9999");

wsServer.Start(socket =>
{
Expand Down Expand Up @@ -150,10 +151,6 @@ public static async Task<WebApplication> StartApi(string[] args)
};
});

// Connect and subscribe to MQTT
var mqttSubscriberService = app.Services.GetRequiredService<MqttSubscriberService>();
_ = mqttSubscriberService.SubscribeAsync();

return app;
}
}

0 comments on commit f271cb2

Please sign in to comment.