Integrate LuaJIT as an optional runtime for better performance, with a fallback to standard Lua 5.4. Update Dockerfile to install LuaJIT and create a wrapper script for execution. Enhance network module with socket fallback support and update README to reflect these changes and configuration options.
49 lines
1.5 KiB
Lua
49 lines
1.5 KiB
Lua
-- Configuration module for auto-boot-ollama-host
|
|
-- Handles all environment variable configuration with defaults
|
|
|
|
local function getenv(name, def)
|
|
local v = os.getenv(name)
|
|
return (v ~= nil and v ~= "") and v or def
|
|
end
|
|
|
|
local config = {}
|
|
|
|
-- Docker configuration
|
|
config.CONTAINER_NAME = getenv("CONTAINER_NAME", "paperless-ai")
|
|
config.SINCE = getenv("SINCE", "0s")
|
|
|
|
-- Ollama service configuration
|
|
config.OLLAMA_HOST = getenv("OLLAMA_HOST", "192.168.222.12")
|
|
config.OLLAMA_PORT = tonumber(getenv("OLLAMA_PORT", "11434"))
|
|
|
|
-- SSH configuration
|
|
config.SSH_PORT = tonumber(getenv("SSH_PORT", "22"))
|
|
config.SSH_USER = getenv("SSH_USER", "user")
|
|
config.SSH_IDENTITY_FILE = getenv("SSH_IDENTITY_FILE", "/root/.ssh/id_rsa")
|
|
|
|
-- Pattern configuration
|
|
config.ERROR_PATTERN = getenv(
|
|
"ERROR_PATTERN",
|
|
("[ERROR] Document analysis failed: connect EHOSTUNREACH %s:%d"):format(
|
|
config.OLLAMA_HOST,
|
|
config.OLLAMA_PORT
|
|
)
|
|
)
|
|
config.FINISH_PATTERN = getenv("FINISH_PATTERN", "[DEBUG] Finished fetching. Found 0 documents.")
|
|
|
|
-- Wake-on-LAN configuration
|
|
config.WOL_MAC = getenv("WOL_MAC", "")
|
|
config.WOL_BCAST = getenv("WOL_BCAST", "192.168.222.255")
|
|
config.WOL_PORT = tonumber(getenv("WOL_PORT", "9"))
|
|
|
|
-- Optional: wait for service to come up (kept commented to stay minimal)
|
|
-- config.UP_WAIT_TIMEOUT = tonumber(getenv("UP_WAIT_TIMEOUT", "90"))
|
|
|
|
-- Debug configuration
|
|
function config.is_debug()
|
|
local debug_env = os.getenv("DEBUG")
|
|
return debug_env and (string.lower(debug_env) == "true" or debug_env == "1")
|
|
end
|
|
|
|
return config
|