Skip to main content

Configuration Overview

Configuration uses environment variables or command-line flags. Command-line flags take precedence over environment variables.

Security Reminder

Mahresources has no built-in authentication or authorization. It is designed for private, trusted networks only. Do not expose it to the public internet without a reverse proxy with proper authentication.

Configuration Methods

Environment Variables

Create a .env file in your working directory:

DB_TYPE=SQLITE
DB_DSN=./mahresources.db
FILE_SAVE_PATH=./files
BIND_ADDRESS=:8181

Command-Line Flags

Pass flags directly when starting the server:

./mahresources -db-type=SQLITE -db-dsn=./mahresources.db -file-save-path=./files -bind-address=:8181
Precedence

Command-line flags take precedence over environment variables, so a flag overrides the same setting from .env.

Quick Reference

FlagEnv VariableDescriptionDefault
-db-typeDB_TYPEDatabase type: SQLITE or POSTGRES-
-db-dsnDB_DSNDatabase connection string-
-db-readonly-dsnDB_READONLY_DSNRead-only database connection-
-db-log-fileDB_LOG_FILEDB log output: STDOUT, empty, or file path-
-file-save-pathFILE_SAVE_PATHMain file storage directory-
-bind-addressBIND_ADDRESSServer address:port-
-memory-dbMEMORY_DB=1Use in-memory SQLite databasefalse
-memory-fsMEMORY_FS=1Use in-memory filesystemfalse
-ephemeralEPHEMERAL=1Fully ephemeral mode (memory DB + FS)false
-seed-dbSEED_DBSQLite file to seed memory-db-
-seed-fsSEED_FSDirectory for copy-on-write base-
-alt-fsFILE_ALT_*Alternative file systems-
-ffmpeg-pathFFMPEG_PATHPath to FFmpeg binaryauto-detect
-libreoffice-pathLIBREOFFICE_PATHPath to LibreOffice binaryauto-detect
-skip-ftsSKIP_FTS=1Skip Full-Text Search initializationfalse
-skip-version-migrationSKIP_VERSION_MIGRATION=1Skip resource version migrationfalse
-max-db-connectionsMAX_DB_CONNECTIONSDatabase connection pool size0 (no limit)
-hash-worker-countHASH_WORKER_COUNTConcurrent hash workers4
-hash-batch-sizeHASH_BATCH_SIZEResources per batch500
-hash-poll-intervalHASH_POLL_INTERVALTime between batch cycles1m
-hash-similarity-thresholdHASH_SIMILARITY_THRESHOLDMax Hamming distance for similarity10
-hash-worker-disabledHASH_WORKER_DISABLED=1Disable background hash workerfalse
-hash-cache-sizeHASH_CACHE_SIZEMax entries in hash similarity cache100000
-thumb-worker-countTHUMB_WORKER_COUNTConcurrent thumbnail workers2
-thumb-worker-disabledTHUMB_WORKER_DISABLED=1Disable thumbnail workerfalse
-thumb-batch-sizeTHUMB_BATCH_SIZEVideos per backfill cycle10
-thumb-poll-intervalTHUMB_POLL_INTERVALTime between backfill cycles1m
-thumb-backfillTHUMB_BACKFILL=1Backfill thumbnails for existing videosfalse
-video-thumb-timeoutVIDEO_THUMB_TIMEOUTTimeout for FFmpeg thumbnail generation30s
-video-thumb-lock-timeoutVIDEO_THUMB_LOCK_TIMEOUTTimeout waiting for thumbnail lock60s
-video-thumb-concurrencyVIDEO_THUMB_CONCURRENCYMax concurrent video thumbnail jobs4
-remote-connect-timeoutREMOTE_CONNECT_TIMEOUTTimeout for remote connections30s
-remote-idle-timeoutREMOTE_IDLE_TIMEOUTTimeout for idle transfers60s
-remote-overall-timeoutREMOTE_OVERALL_TIMEOUTMaximum total download time30m
-share-portSHARE_PORTPort for public share server(disabled)
-share-bind-addressSHARE_BIND_ADDRESSShare server bind address0.0.0.0
-cleanup-logs-daysCLEANUP_LOGS_DAYSDelete log entries older than N days on startup0 (disabled)
-plugin-pathPLUGIN_PATHDirectory to scan for plugins./plugins
-plugins-disabledPLUGINS_DISABLED=1Disable the plugin system entirelyfalse

Common Configurations

Minimal Production Setup

./mahresources \
-db-type=SQLITE \
-db-dsn=./data/mahresources.db \
-file-save-path=./data/files \
-bind-address=:8181

Development/Testing (Ephemeral)

No persistence -- all data is lost when the server stops:

./mahresources -ephemeral -bind-address=:8181

Demo with Seeded Data

Load existing data for demos (changes stay in memory):

./mahresources \
-ephemeral \
-seed-db=./production.db \
-seed-fs=./production-files \
-bind-address=:8181

PostgreSQL with Read Replica

./mahresources \
-db-type=POSTGRES \
-db-dsn="host=primary.db user=app password=secret dbname=mahresources" \
-db-readonly-dsn="host=replica.db user=app password=secret dbname=mahresources" \
-file-save-path=/var/lib/mahresources/files \
-bind-address=:8181

Next Steps