Commit bac7e381 authored by Renato Figueiro Maia's avatar Renato Figueiro Maia
Browse files

Merge branch 'newfeature/SOMA-3993_GenerateTagAutomaticDirs' into 'developer'

[SOMA-3993] Geração dos diretórios sandbox e runtime ao subir o SGA

See merge request !40
parents 38ac5b68 0f419718
......@@ -42,7 +42,7 @@ RUN mkdir sgarest-daemon && \
WORKDIR /sgad
RUN mkdir projects && mkdir algorithms && mkdir logs && mkdir -p /tmp/sgad/sandbox
RUN mkdir projects && mkdir algorithms && mkdir logs
RUN cp ../sgarest-daemon/collect_execution_data .
RUN cp ../sgarest-daemon/flowmonitor .
RUN rm -rf ../sgarest-daemon
......
......@@ -42,7 +42,7 @@ RUN mkdir sgarest-daemon && \
WORKDIR /sgad
RUN mkdir projects && mkdir algorithms && mkdir logs && mkdir -p /tmp/sgad/sandbox
RUN mkdir projects && mkdir algorithms && mkdir logs
RUN cp ../sgarest-daemon/collect_execution_data .
RUN cp ../sgarest-daemon/flowmonitor .
RUN rm -rf ../sgarest-daemon
......
......@@ -36,6 +36,18 @@ local function make_logger(ident)
end))
end
local function rmkdir(fullpath)
if lfs.attributes(fullpath, "mode") ~= nil then
return true
end
local basename = fullpath:gsub("[^/]+/*$", "")
if string.find(basename, "%S") ~= nil then
local ok, err = rmkdir(basename)
if not ok then return nil, err end
end
return lfs.mkdir(fullpath)
end
--[[
Application architecture:
......@@ -59,12 +71,14 @@ end
--]]
function application.new(config)
local ok, err = lfs.mkdir(config.runtime_data_dir)
local ok, err = rmkdir(config.runtime_data_dir)
if not ok then
return nil, "Failed creating runtime data dir "..config.runtime_data_dir
end
local ok, err = rmkdir(config.sandbox_root_dir)
if not ok then
local attr = lfs.attributes(config.runtime_data_dir)
if not (attr and attr.mode == "directory") then
return nil, "Failed creating runtime data dir "..config.runtime_data_dir
end
return nil, "Failed creating sandbox root dir "..config.sandbox_root_dir
end
local client_object = client.new(config, make_logger("sga.client"))
......
......@@ -39,13 +39,5 @@ if [ -z ${configfile} ]; then
configfile=sgad.cfg
fi
hostruntimedir="/tmp/chuva"
sgadruntimedir="${hostruntimedir}/sgad"
runtimesandboxdir="${sgadruntimedir}/sandbox"
[ ! -e $hostruntimedir ] && echo "mkdir $hostruntimedir..." && mkdir $hostruntimedir
[ ! -e $sgadruntimedir ] && echo "mkdir $sgadruntimedir..." && mkdir $sgadruntimedir
[ ! -e $runtimesandboxdir ] && echo "mkdir $runtimesandboxdir..." && mkdir $runtimesandboxdir
eval $(luarocks path --bin)
sgad ${configfile} ${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