fix: remove err msg in docker (#1356)
This commit is contained in:
@@ -412,9 +412,7 @@ function M.setup(opts)
|
|||||||
end
|
end
|
||||||
vim.schedule(function()
|
vim.schedule(function()
|
||||||
Utils.info("Starting Rag Service ...")
|
Utils.info("Starting Rag Service ...")
|
||||||
RagService.launch_rag_service()
|
RagService.launch_rag_service(add_resource_with_delay)
|
||||||
Utils.info("Launched Rag Service")
|
|
||||||
add_resource_with_delay()
|
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -29,12 +29,12 @@ function M.get_current_image()
|
|||||||
return image
|
return image
|
||||||
end
|
end
|
||||||
|
|
||||||
---@return boolean already_running
|
---@param cb fun()
|
||||||
function M.launch_rag_service()
|
function M.launch_rag_service(cb)
|
||||||
local openai_api_key = os.getenv("OPENAI_API_KEY")
|
local openai_api_key = os.getenv("OPENAI_API_KEY")
|
||||||
if openai_api_key == nil then
|
if openai_api_key == nil then
|
||||||
error("cannot launch avante rag service, OPENAI_API_KEY is not set")
|
error("cannot launch avante rag service, OPENAI_API_KEY is not set")
|
||||||
return false
|
return
|
||||||
end
|
end
|
||||||
local openai_base_url = os.getenv("OPENAI_BASE_URL")
|
local openai_base_url = os.getenv("OPENAI_BASE_URL")
|
||||||
if openai_base_url == nil then openai_base_url = "https://api.openai.com/v1" end
|
if openai_base_url == nil then openai_base_url = "https://api.openai.com/v1" end
|
||||||
@@ -46,7 +46,10 @@ function M.launch_rag_service()
|
|||||||
if result ~= "" then
|
if result ~= "" then
|
||||||
Utils.debug(string.format("container %s already running", container_name))
|
Utils.debug(string.format("container %s already running", container_name))
|
||||||
local current_image = M.get_current_image()
|
local current_image = M.get_current_image()
|
||||||
if current_image == image then return false end
|
if current_image == image then
|
||||||
|
cb()
|
||||||
|
return
|
||||||
|
end
|
||||||
Utils.debug(
|
Utils.debug(
|
||||||
string.format(
|
string.format(
|
||||||
"container %s is running with different image: %s != %s, stopping...",
|
"container %s is running with different image: %s != %s, stopping...",
|
||||||
@@ -70,19 +73,15 @@ function M.launch_rag_service()
|
|||||||
)
|
)
|
||||||
vim.fn.jobstart(cmd_, {
|
vim.fn.jobstart(cmd_, {
|
||||||
detach = true,
|
detach = true,
|
||||||
on_stderr = function(_, data, _)
|
|
||||||
Utils.error(string.format("container %s failed to start: %s", container_name, data))
|
|
||||||
end,
|
|
||||||
on_exit = function(_, exit_code)
|
on_exit = function(_, exit_code)
|
||||||
if exit_code ~= 0 then
|
if exit_code ~= 0 then
|
||||||
Utils.error(string.format("container %s failed to start, exit code: %d", container_name, exit_code))
|
Utils.error(string.format("container %s failed to start, exit code: %d", container_name, exit_code))
|
||||||
else
|
else
|
||||||
Utils.debug(string.format("container %s started", container_name))
|
Utils.debug(string.format("container %s started", container_name))
|
||||||
|
cb()
|
||||||
end
|
end
|
||||||
return true
|
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.stop_rag_service()
|
function M.stop_rag_service()
|
||||||
|
|||||||
Reference in New Issue
Block a user