Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deployed #23

Merged
merged 7 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}
Loading