mirror of
https://github.com/C9Glax/tranga.git
synced 2025-10-11 05:09:49 +02:00
Move EnvVars to Constants.cs
Add CHECK_CHAPTERS_BEFORE_START
This commit is contained in:
@@ -7,4 +7,13 @@ public struct Constants
|
|||||||
public static readonly Size ImageSmSize = new (225, 320);
|
public static readonly Size ImageSmSize = new (225, 320);
|
||||||
public static readonly Size ImageMdSize = new (450, 640);
|
public static readonly Size ImageMdSize = new (450, 640);
|
||||||
public static readonly Size ImageLgSize = new (900, 1280);
|
public static readonly Size ImageLgSize = new (900, 1280);
|
||||||
|
|
||||||
|
public static readonly string PostgresHost = Environment.GetEnvironmentVariable("POSTGRES_HOST") ?? "tranga-pg:5432";
|
||||||
|
public static readonly string PostgresDb = Environment.GetEnvironmentVariable("POSTGRES_DB") ?? "postgres";
|
||||||
|
public static readonly string PostgresUser = Environment.GetEnvironmentVariable("POSTGRES_USER") ?? "postgres";
|
||||||
|
public static readonly string PostgresPassword = Environment.GetEnvironmentVariable("POSTGRES_PASSWORD") ?? "postgres";
|
||||||
|
public static readonly int PostgresConnectionTimeout = int.Parse(Environment.GetEnvironmentVariable("POSTGRES_CONNECTION_TIMEOUT") ?? "30");
|
||||||
|
public static readonly int PostgresCommandTimeout = int.Parse(Environment.GetEnvironmentVariable("POSTGRES_COMMAND_TIMEOUT") ?? "60");
|
||||||
|
|
||||||
|
public static readonly bool UpdateChaptersDownloadedBeforeStarting = bool.Parse(Environment.GetEnvironmentVariable("CHECK_CHAPTERS_BEFORE_START") ?? "true");
|
||||||
}
|
}
|
@@ -75,15 +75,15 @@ builder.Services.AddSwaggerGenNewtonsoftSupport().AddSwaggerGen(opt =>
|
|||||||
log.Debug("Adding Database-Connection...");
|
log.Debug("Adding Database-Connection...");
|
||||||
NpgsqlConnectionStringBuilder connectionStringBuilder = new()
|
NpgsqlConnectionStringBuilder connectionStringBuilder = new()
|
||||||
{
|
{
|
||||||
Host = Environment.GetEnvironmentVariable("POSTGRES_HOST") ?? "tranga-pg:5432",
|
Host = Constants.PostgresHost,
|
||||||
Database = Environment.GetEnvironmentVariable("POSTGRES_DB") ?? "postgres",
|
Database = Constants.PostgresDb,
|
||||||
Username = Environment.GetEnvironmentVariable("POSTGRES_USER") ?? "postgres",
|
Username = Constants.PostgresUser,
|
||||||
Password = Environment.GetEnvironmentVariable("POSTGRES_PASSWORD") ?? "postgres",
|
Password = Constants.PostgresPassword,
|
||||||
ConnectionLifetime = 300,
|
ConnectionLifetime = 300,
|
||||||
Timeout = int.Parse(Environment.GetEnvironmentVariable("POSTGRES_CONNECTION_TIMEOUT") ?? "30"),
|
Timeout = Constants.PostgresConnectionTimeout,
|
||||||
ReadBufferSize = 65536,
|
ReadBufferSize = 65536,
|
||||||
WriteBufferSize = 65536,
|
WriteBufferSize = 65536,
|
||||||
CommandTimeout = int.Parse(Environment.GetEnvironmentVariable("POSTGRES_COMMAND_TIMEOUT") ?? "60"),
|
CommandTimeout = Constants.PostgresCommandTimeout,
|
||||||
ApplicationName = "Tranga"
|
ApplicationName = "Tranga"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -39,8 +39,11 @@ public static class Tranga
|
|||||||
{
|
{
|
||||||
AddWorker(SendNotificationsWorker);
|
AddWorker(SendNotificationsWorker);
|
||||||
AddWorker(CleanupMangaconnectorIdsWithoutConnector);
|
AddWorker(CleanupMangaconnectorIdsWithoutConnector);
|
||||||
AddWorker(UpdateChaptersDownloadedWorker);
|
|
||||||
AddWorker(CleanupMangaCoversWorker);
|
AddWorker(CleanupMangaCoversWorker);
|
||||||
|
|
||||||
|
if(Constants.UpdateChaptersDownloadedBeforeStarting)
|
||||||
|
AddWorker(UpdateChaptersDownloadedWorker);
|
||||||
|
|
||||||
Log.Info("Waiting for startup to complete...");
|
Log.Info("Waiting for startup to complete...");
|
||||||
while (new List<BaseWorker>() { CleanupMangaconnectorIdsWithoutConnector, UpdateChaptersDownloadedWorker, CleanupMangaCoversWorker}.Any(w => w.State < WorkerExecutionState.Completed))
|
while (new List<BaseWorker>() { CleanupMangaconnectorIdsWithoutConnector, UpdateChaptersDownloadedWorker, CleanupMangaCoversWorker}.Any(w => w.State < WorkerExecutionState.Completed))
|
||||||
Thread.Sleep(100);
|
Thread.Sleep(100);
|
||||||
@@ -54,6 +57,9 @@ public static class Tranga
|
|||||||
AddWorker(StartNewChapterDownloadsWorker);
|
AddWorker(StartNewChapterDownloadsWorker);
|
||||||
AddWorker(RemoveOldNotificationsWorker);
|
AddWorker(RemoveOldNotificationsWorker);
|
||||||
AddWorker(UpdateCoversWorker);
|
AddWorker(UpdateCoversWorker);
|
||||||
|
|
||||||
|
if(!Constants.UpdateChaptersDownloadedBeforeStarting)
|
||||||
|
AddWorker(UpdateChaptersDownloadedWorker);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static bool TryGetMangaConnector(string name, [NotNullWhen(true)]out MangaConnector? mangaConnector)
|
internal static bool TryGetMangaConnector(string name, [NotNullWhen(true)]out MangaConnector? mangaConnector)
|
||||||
|
@@ -10,7 +10,7 @@ public class UpdateChaptersDownloadedWorker(TimeSpan? interval = null, IEnumerab
|
|||||||
: BaseWorkerWithContext<MangaContext>(dependsOn), IPeriodic
|
: BaseWorkerWithContext<MangaContext>(dependsOn), IPeriodic
|
||||||
{
|
{
|
||||||
public DateTime LastExecution { get; set; } = DateTime.UnixEpoch;
|
public DateTime LastExecution { get; set; } = DateTime.UnixEpoch;
|
||||||
public TimeSpan Interval { get; set; } = interval??TimeSpan.FromMinutes(60);
|
public TimeSpan Interval { get; set; } = interval??TimeSpan.FromDays(1);
|
||||||
protected override async Task<BaseWorker[]> DoWorkInternal()
|
protected override async Task<BaseWorker[]> DoWorkInternal()
|
||||||
{
|
{
|
||||||
Log.Debug("Checking chapter files...");
|
Log.Debug("Checking chapter files...");
|
||||||
|
@@ -138,6 +138,7 @@ The file also includes [tranga-website](https://github.com/C9Glax/tranga-website
|
|||||||
| FLARESOLVERR_URL | <empty> |
|
| FLARESOLVERR_URL | <empty> |
|
||||||
| POSTGRES_COMMAND_TIMEOUT | [`60`](https://www.npgsql.org/doc/connection-string-parameters.html?q=Command%20Timeout) |
|
| POSTGRES_COMMAND_TIMEOUT | [`60`](https://www.npgsql.org/doc/connection-string-parameters.html?q=Command%20Timeout) |
|
||||||
| POSTGRES_CONNECTION_TIMEOUT | `30` |
|
| POSTGRES_CONNECTION_TIMEOUT | `30` |
|
||||||
|
| CHECK_CHAPTERS_BEFORE_START | `true` |
|
||||||
|
|
||||||
For compatibility do not execute the compose as root (which you should not do anyways...) but as user that can
|
For compatibility do not execute the compose as root (which you should not do anyways...) but as user that can
|
||||||
access the folder. Permission conflicts with Komga and Kavita should thus be limited.
|
access the folder. Permission conflicts with Komga and Kavita should thus be limited.
|
||||||
|
Reference in New Issue
Block a user