Commit 9707dbc5 authored by Carla Goncalves Ourofino's avatar Carla Goncalves Ourofino
Browse files

Nova opção --debug para mostrar configuração processada.

[SOMA-3827][SOMA-4195]
parent 578a19ed
......@@ -2,6 +2,7 @@
local args = { ... }
local safer = require("safer")
local util = require("sga.util")
module = nil -- needed for luasocket setting a global variable if Lua 5.2
......@@ -20,7 +21,7 @@ local function script_path()
return str:match("(.*)/") or "."
end
local config, message = configuration.read(args[1] or os.getenv("SGAD_CONFIG_FILE") or script_path().."/sgad.cfg", args[2])
local config, message = configuration.read(args[1] or os.getenv("SGAD_CONFIG_FILE") or script_path().."/sgad.cfg", args[3])
if message then
io.stderr:write(message.."\n")
end
......@@ -28,7 +29,18 @@ if not config then
os.exit(1)
end
io.stderr:write("\27[1;32m".."sgad starting '"..config.sga_name.."'...".."\27[0m\n")
-- Show config debug
if type(args[2]) == "boolean" and args[2] or ({ [0]=false, [1]=true })[tonumber(args[2])] then
local is_readonly = not next(config) and getmetatable(config)
local t = is_readonly and getmetatable(config).__index or config
print("============= DEBUG CONFIG =============")
print(util.debug_table(t))
print("========================================")
end
if config.sga_name then
io.stderr:write("\27[1;32m".."sgad starting '"..config.sga_name.."'...".."\27[0m\n")
end
configuration.check(config)
local app, err = application.new(config)
......
......@@ -10,10 +10,12 @@ logfile="logs/sgad_${timestamp}.log"
usage() {
echo "usage: $0 [configfile] [options]"
echo "Available options are:"
echo " --sga_name SGA name to get config from a multiple config file"
echo " --sga_name NAME SGA name to get config from a multiple config file"
echo " --debug Enable debug information: show interpreted configuration."
}
POSITIONAL="" # String para salvar argumentos passados ao comando
debug=0
while [ $# -gt 0 ] # Percorre todos argumentos
do
case "$1" in
......@@ -26,6 +28,10 @@ do
sga_name="${1#*=}"
shift
;;
--debug)
debug=1
shift
;;
--*)
echo "$0: unrecognized option '$1'"
usage
......@@ -50,4 +56,4 @@ if [ -z ${configfile} ]; then
fi
eval $(luarocks path --bin)
sgad ${configfile} ${sga_name} 2>&1 | tee -a "${logfile}"
sgad ${configfile} ${debug} ${sga_name} 2>&1 | tee -a "${logfile}"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment