feat(server): API v1 with auth, uploads, sync, jobs, render nodes and events
- Security: PBKDF2-SHA512 (210,000 iterations) hashes, opaque bearer tokens stored as SHA-256 with sliding expiry and revocation, HttpOnly/Secure/ SameSite=Strict admin cookie with a session-bound CSRF token, sign-in rate limit and lockout, role/permission metadata on every endpoint, audit log, first-run administrator bootstrap. - Sequences with keyset paging, ETags and settings_version conflicts; sync manifest; frames, proxies, thumbnails and exports streamed with Range. - Chunked resumable uploads with hash short-circuit, quota and disk checks, staging on the archive volume, SHA-256 verification and IArchiveIngest. - Job engine host, jobs API, render nodes with heartbeat timeout and reassignment, WebSocket events, LAN discovery beacon, upload cleanup. - Windows service host over advapi32 (--service, --install-service, --uninstall-service); fails fast without the archive module services. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
56 files changed
+4726
-108
No files matched your search
@@ -0,0 +1,68 @@
|
||||
namespace Titano.Server.Hosting;
|
||||
|
||||
/// <summary>What <c>Titano.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 = """
|
||||
Titano Server — time-lapse archive, uploads, jobs and rendering.
|
||||
|
||||
Usage: Titano.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 "TitanoServer" 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 (TITANO_DATA_PATH) overridden by environment variables:
|
||||
TITANO_ARCHIVE_PATH TITANO_DATA_PATH TITANO_SERVER_NAME TITANO_ADMIN_USER TITANO_ADMIN_PASSWORD
|
||||
TITANO_DB (postgres | sqlite | connection string) TITANO_DB_HOST TITANO_DB_PORT TITANO_DB_NAME TITANO_DB_USER
|
||||
TITANO_DB_PASSWORD TITANO_DB_SSLMODE TITANO_HTTP_PORT TITANO_HTTPS_PORT TITANO_TLS_MODE (auto | pem | proxy)
|
||||
TITANO_TLS_CERT TITANO_TLS_KEY TITANO_LANG TITANO_WORKERS TITANO_DISCOVERY
|
||||
""";
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user