Files
auto-boot-ollama-host/scripts/utils.lua
Bastian (BaM) 8cb6d55782 Refactor to use LuaJIT and improve performance
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.
2025-09-15 08:44:19 +02:00

30 lines
764 B
Lua

-- Utility functions module for auto-boot-ollama-host
-- Provides logging and other utility functions
local utils = {}
-- Logging function with timestamp
function utils.log(msg)
io.stdout:write(os.date("[%F %T] "), msg, "\n")
io.stdout:flush()
end
-- Get environment variable with default value
function utils.getenv(name, def)
local v = os.getenv(name)
return (v ~= nil and v ~= "") and v or def
end
-- Sleep function with fallback support for LuaJIT compatibility
function utils.sleep(seconds)
-- Try to use socket.sleep if available, fallback to os.execute
local ok, socket = pcall(require, "socket")
if ok and socket and socket.sleep then
socket.sleep(seconds)
else
os.execute("sleep " .. tostring(seconds))
end
end
return utils