You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
764 B
29 lines
764 B
-- 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
|
|
|