Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serf log is stored in the nginx_working_dir #975

Merged
merged 1 commit into from
Feb 10, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions kong/cli/services/serf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ local dao = require "kong.tools.dao_loader"
local Serf = BaseService:extend()

local SERVICE_NAME = "serf"
local LOG_FILE = "/tmp/"..SERVICE_NAME..".log"
local START_TIMEOUT = 10
local EVENT_NAME = "kong"

function Serf:new(configuration)
local nginx_working_dir = configuration.nginx_working_dir

self._configuration = configuration
self._script_path = nginx_working_dir
local path_prefix = nginx_working_dir
..(stringy.endswith(nginx_working_dir, "/") and "" or "/")
.."serf_event.sh"
self._script_path = path_prefix.."serf_event.sh"
self._log_path = path_prefix.."serf.log"
self._dao_factory = dao.load(self._configuration)
Serf.super.new(self, SERVICE_NAME, nginx_working_dir)
end
Expand Down Expand Up @@ -155,12 +155,12 @@ function Serf:start()

setmetatable(cmd_args, require "kong.tools.printable")
local str_cmd_args = tostring(cmd_args)
local res, code = IO.os_execute("nohup "..cmd.." agent "..str_cmd_args.." > "..LOG_FILE.." 2>&1 & echo $! > "..self._pid_file_path)
local res, code = IO.os_execute("nohup "..cmd.." agent "..str_cmd_args.." > "..self._log_path.." 2>&1 & echo $! > "..self._pid_file_path)
if code == 0 then

-- Wait for process to start, with a timeout
local start = os.time()
while not (IO.file_exists(LOG_FILE) and string.match(IO.read_file(LOG_FILE), "running") or (os.time() > start + START_TIMEOUT)) do
while not (IO.file_exists(self._log_path) and string.match(IO.read_file(self._log_path), "running") or (os.time() > start + START_TIMEOUT)) do
-- Wait
end

Expand All @@ -171,7 +171,7 @@ function Serf:start()
return self:_autojoin(node_name)
else
-- Get last error message
local parts = stringy.split(IO.read_file(LOG_FILE), "\n")
local parts = stringy.split(IO.read_file(self._log_path), "\n")
return nil, "Could not start serf: "..string.gsub(parts[#parts - 1], "==> ", "")
end
else
Expand Down