S-UI Environment Variables: Complete Configuration Guide with Default Values
S-UI respects four environment variables—SUI_LOG_LEVEL, SUI_DEBUG, SUI_DB_FOLDER, and SUI_BIN_FOLDER—which default to info, false, platform-specific paths, and bin respectively when unset.
The S-UI panel (alireza0/s-ui) reads environment variables at runtime to configure logging, debugging, and storage paths without requiring code changes. Understanding these variables helps administrators deploy the application across different environments while maintaining predictable behavior.
Overview of S-UI Environment Variables
S-UI centralizes its configuration logic in config/config.go, where helper functions read environment variables and apply hardcoded defaults when values are missing. The migration subsystem in cmd/migration/1_2.go introduces one additional variable specific to legacy data imports.
| Variable | Default Value | Purpose |
|---|---|---|
SUI_LOG_LEVEL |
info |
Controls logging verbosity |
SUI_DEBUG |
false |
Enables debug mode when set to "true" |
SUI_DB_FOLDER |
Platform-specific | Directory for the SQLite database |
SUI_BIN_FOLDER |
bin |
Folder containing legacy config.json for migrations |
Detailed Variable Reference
SUI_LOG_LEVEL (Logging Verbosity)
The SUI_LOG_LEVEL variable determines the application's logging threshold. Valid values include debug, info, warn, and error.
According to config/config.go (lines 39-44), the GetLogLevel() function checks this variable and falls back to the Info constant when the variable is empty. If SUI_DEBUG is enabled, this setting is overridden to debug regardless of the environment value.
lvl := config.GetLogLevel() // Returns "info" if SUI_LOG_LEVEL is unset
fmt.Println("Current log level:", lvl)
SUI_DEBUG (Debug Mode Toggle)
Setting SUI_DEBUG=true forces the application into debug mode. As implemented in config/config.go (lines 46-48), the IsDebug() function returns true only when the environment variable exactly matches the string "true".
When active, this variable overrides SUI_LOG_LEVEL to ensure debug messages are captured.
if config.IsDebug() {
log.Println("Debug mode enabled via SUI_DEBUG")
}
SUI_DB_FOLDER (Database Directory)
SUI_DB_FOLDER specifies where S-UI stores its SQLite database file. The GetDBFolderPath() function in config/config.go (lines 50-63) implements platform-aware defaults when this variable is unset:
- Windows:
C:\Program Files\s-ui\db - Linux/macOS:
/usr/local/s-ui/db - Fallback:
<binary-directory>/db
The GetDBPath() function appends s-ui.db to this folder path to generate the final database file location.
dbPath := config.GetDBPath() // e.g., "/usr/local/s-ui/db/s-ui.db"
fmt.Println("Database location:", dbPath)
SUI_BIN_FOLDER (Migration Binary Folder)
Used exclusively by the migration system in cmd/migration/1_2.go (lines 22-25), SUI_BIN_FOLDER identifies the directory containing the legacy config.json file during version upgrades. Unlike other variables, this defaults simply to the string "bin" relative to the working directory.
binFolder := os.Getenv("SUI_BIN_FOLDER")
if binFolder == "" {
binFolder = "bin" // Default as per cmd/migration/1_2.go
}
How Defaults Are Applied Internally
The configuration logic follows a consistent pattern across the codebase:
-
Log Level Resolution:
GetLogLevel()first checksIsDebug(); if true, it returnsdebug. Otherwise, it readsSUI_LOG_LEVELor defaults toInfo. -
Debug Detection:
IsDebug()performs a direct string comparison against"true", returningfalsefor any other value or empty string. -
Path Construction:
GetDBFolderPath()usesos.Getenv()to detect the environment variable. When empty, it callsos.Executable()to determine the binary location, then applies OS-specific logic to build the appropriate path. -
Migration Context: The migration helper uses
os.Getenv()directly with a hardcoded fallback to"bin", as this code runs outside the main configuration initialization.
Practical Configuration Examples
Run S-UI with custom logging and database locations:
# Enable debug logging and custom database path
SUI_DEBUG=true SUI_DB_FOLDER=/var/lib/s-ui ./s-ui
Docker deployment with explicit variable settings:
docker run -e SUI_LOG_LEVEL=warn -e SUI_DB_FOLDER=/data alireza0/s-ui
Programmatically checking configuration in Go:
package main
import (
"fmt"
"github.com/alireza0/s-ui/config"
)
func main() {
fmt.Printf("Log Level: %s\n", config.GetLogLevel())
fmt.Printf("Debug Mode: %t\n", config.IsDebug())
fmt.Printf("DB Path: %s\n", config.GetDBPath())
}
Summary
- SUI_LOG_LEVEL defaults to
infoand controls message verbosity viaGetLogLevel()inconfig/config.go - SUI_DEBUG defaults to
falseand forces debug logging when set to"true" - SUI_DB_FOLDER uses platform-specific paths (Windows:
C:\Program Files\s-ui\db, Unix:/usr/local/s-ui/db) when unset, resolved byGetDBFolderPath() - SUI_BIN_FOLDER defaults to
"bin"and is only used during legacy migrations incmd/migration/1_2.go - All defaults are applied at runtime, allowing flexible deployment without recompilation
Frequently Asked Questions
What is the default log level in S-UI?
The default log level is info. According to config/config.go lines 39-44, the GetLogLevel() function returns the Info constant when SUI_LOG_LEVEL is unset and debug mode is disabled.
How do I enable debug mode in S-UI?
Set the environment variable SUI_DEBUG=true. The IsDebug() function in config/config.go checks for this exact string value. When enabled, it automatically forces the log level to debug regardless of the SUI_LOG_LEVEL setting.
Where does S-UI store its database by default?
The default location depends on your operating system. As defined in config/config.go lines 50-63, S-UI uses C:\Program Files\s-ui\db on Windows, /usr/local/s-ui/db on other operating systems, or falls back to a db folder adjacent to the binary if those paths are inaccessible.
Is SUI_BIN_FOLDER required for new installations?
No. SUI_BIN_FOLDER is only used by the migration system in cmd/migration/1_2.go for importing legacy config.json files during upgrades from older versions. Fresh installations can ignore this variable, as it defaults to "bin" when unspecified.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →