Move services check at startup

This commit is contained in:
emanuele-f 2018-11-26 12:04:45 +01:00
parent 919436037c
commit 6ca5e38587
4 changed files with 32 additions and 14 deletions

View file

@ -76,18 +76,12 @@ end
--! @return true if service is available, false otherwise.
function os_utils.hasService(service_name, ...)
local cmd = ntopctl_cmd(service_name, "has-service", ...)
local key = "ntopng.cache.hasService." .. cmd:gsub(" ", "_")
local rv = ntop.getCache(key)
if rv == nil then
if not ntop.exists(NTOPNG_CONFIG_TOOL) then
return false
end
rv = os_utils.execWithOutput(cmd)
ntop.setCache(key, rv, 60)
if not ntop.exists(NTOPNG_CONFIG_TOOL) then
return false
end
local rv = os_utils.execWithOutput(cmd)
return(rv == "yes\n")
end