Files
Chronos/src/Chronos.Server/Hosting/ServerCommandLine.cs
T
Alby96andClaude Opus 5.5 728ffa35cb
CI / Build and test (push) Successful in 9m41s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 9s
Release / Build, test and publish (push) Successful in 14m49s
CI / PostgreSQL 16 integration (push) Successful in 8m51s
CI / PostgreSQL 17 integration (push) Successful in 9m48s
CI / Docker image (push) Successful in 54s
Release / Server image (push) Successful in 1m39s
feat: export panel and Render menu, playback options, videos library (owner review 1 phase 5) (#27)
Owner review 1 R3, R8, R9. A grouped Export step and Render menu; encoding, playback (reverse, boomerang, loops, fades, hold) and still frames; one videos library on the desktop and the server with a verified trash and copies to a videos folder.

Closes #21

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
2026-11-05 09:18:40 +01:00

93 lines
5.2 KiB
C#

namespace Chronos.Server.Hosting;
/// <summary>What <c>Chronos.Server</c> was asked to do.</summary>
public enum ServerCommand
{
/// <summary>Run in the console (Docker, Linux, development).</summary>
Run,
/// <summary>Run under the Windows Service Control Manager (the command line the installed service uses).</summary>
Service,
InstallService,
UninstallService,
/// <summary>Probe <c>/health</c> of the local server and exit 0/1 (container health check).</summary>
HealthCheck,
Help,
}
/// <summary>Command-line switches of the server; anything else is passed on to the web host.</summary>
public sealed record ServerCommandLine(ServerCommand Command, IReadOnlyList<string> HostArguments, string? Error)
{
public const string Usage = """
Chronos Server — time-lapse archive, uploads, jobs and rendering.
Usage: Chronos.Server [--service | --install-service | --uninstall-service | --healthcheck | --help]
(no switch) run in the console until Ctrl+C
--service run under the Windows Service Control Manager
--install-service register the "ChronosServer" Windows service (automatic start, LocalSystem)
--uninstall-service stop and remove the Windows service
--healthcheck exit 0 when the local server answers /health, 1 otherwise
Configuration: /data/server.json (CHRONOS_DATA_PATH) overridden by environment variables:
CHRONOS_ARCHIVE_PATH CHRONOS_DATA_PATH CHRONOS_SERVER_NAME CHRONOS_ADMIN_USER CHRONOS_ADMIN_PASSWORD
CHRONOS_DB (postgres | sqlite | connection string) CHRONOS_DB_HOST CHRONOS_DB_PORT CHRONOS_DB_NAME CHRONOS_DB_USER
CHRONOS_DB_PASSWORD CHRONOS_DB_SSLMODE CHRONOS_HTTP_PORT CHRONOS_HTTPS_PORT CHRONOS_TLS_MODE (auto | pem | proxy)
CHRONOS_TLS_CERT CHRONOS_TLS_KEY CHRONOS_LANG
CHRONOS_SPACE_PATH folder whose volume's free space the admin panel shows (default: the archive's); on
Unraid the share's array view (/mnt/user0/<share>) mapped read-only to /space
CHRONOS_VIDEOS_PATH folder "Copy to videos folder" copies renders into, hash-verified (default: none, copying
off); in a container the /videos volume
CHRONOS_PARALLELISM photos the running job processes at once (jobs run one at a time; default: half the
cores); CHRONOS_WORKERS, its former name, still sets it
CHRONOS_PRIORITY_QUEUE a job of a higher level pauses the running one, which resumes afterwards (true | false)
CHRONOS_LOG_LEVEL least severe level of the log files and the console (Trace | Debug | Information |
Warning | Error | Critical | None; default Information)
CHRONOS_LOG_CONSOLE_LEVEL the console's own level (default: CHRONOS_LOG_LEVEL's)
CHRONOS_LOG_RETENTION_DAYS days log files are kept (default 14)
CHRONOS_LOG_MAX_FILE_MB size at which a log file continues in a numbered one (default 50; 0: no limit)
CHRONOS_LOG_MAX_TOTAL_MB size of all log files; beyond it the oldest are deleted (default 1024; 0: no limit)
CHRONOS_LOG_ROTATION a new log file every day or every hour, UTC (daily | hourly; default daily)
CHRONOS_AUDIT_RETENTION_DAYS days of audit log the audit-cleanup schedule keeps (default 0: forever)
CHRONOS_DIAGNOSTICS_LOG_MB MB from the end of each log file in the diagnostics zip (default 4)
CHRONOS_DISCOVERY LAN beacon (true | false); in a container it needs host networking
CHRONOS_PUBLIC_HTTP_PORT, CHRONOS_PUBLIC_HTTPS_PORT
ports clients reach when the container's ports are published as other host ports
(admin redirect to HTTPS, LAN beacon)
CHRONOS_TRUSTED_PROXIES proxy mode: addresses or networks (CIDR) whose X-Forwarded-* headers count
(default: loopback only; list a proxy in another container or on another machine)
Container image only: PUID, PGID (user and group the server runs as, owners of /data), TZ (time zone of the schedules)
""";
public static ServerCommandLine Parse(IReadOnlyList<string> args)
{
var command = ServerCommand.Run;
var rest = new List<string>();
string? error = null;
foreach (var arg in args)
{
ServerCommand? parsed = arg switch
{
"--service" => ServerCommand.Service,
"--install-service" => ServerCommand.InstallService,
"--uninstall-service" => ServerCommand.UninstallService,
"--healthcheck" => ServerCommand.HealthCheck,
"--help" or "-h" or "-?" or "/?" => ServerCommand.Help,
_ => null,
};
if (parsed is not { } switchCommand)
{
rest.Add(arg);
continue;
}
if (command != ServerCommand.Run && command != switchCommand) error = $"{arg} cannot be combined with another command switch.";
command = switchCommand;
}
return new ServerCommandLine(command, rest, error);
}
}