@@ -327,9 +327,7 @@ function Server:initialize()
327327 local prefix = fio .pathjoin (Server .vardir , ' artifacts' , self .rs_id or ' ' )
328328 self .artifacts = fio .pathjoin (prefix , self .id )
329329
330- if rawget (_G , ' log_file' ) ~= nil then
331- self .unified_log_enabled = true
332- end
330+ self .log_file = fio .pathjoin (self .workdir , self .alias .. ' .log' )
333331end
334332
335333-- Create a table with env variables based on the constructor params.
341339-- * `TARANTOOL_ALIAS`
342340-- * `TARANTOOL_HTTP_PORT`
343341-- * `TARANTOOL_BOX_CFG`
344- -- * `TARANTOOL_UNIFIED_LOG_ENABLED`
345342--
346343-- @return table
347344function Server :build_env ()
@@ -354,9 +351,6 @@ function Server:build_env()
354351 if self .box_cfg ~= nil then
355352 res .TARANTOOL_BOX_CFG = json .encode (self .box_cfg )
356353 end
357- if self .unified_log_enabled then
358- res .TARANTOOL_UNIFIED_LOG_ENABLED = tostring (self .unified_log_enabled )
359- end
360354 return res
361355end
362356
@@ -442,6 +436,7 @@ function Server:start(opts)
442436 self .process = Process :start (command , args , env , {
443437 chdir = self .chdir ,
444438 output_prefix = self .alias ,
439+ output_file = self .log_file ,
445440 })
446441
447442 local wait_until_ready
@@ -573,14 +568,13 @@ function Server:stop()
573568 end
574569 local workdir = fio .basename (self .workdir )
575570 local pid = self .process .pid
576- local stderr = self .process .output_beautifier .stderr
577- if stderr :find (' Segmentation fault' ) then
578- error ((' Segmentation fault during process termination (alias: %s, workdir: %s, pid: %d)\n %s' )
579- :format (self .alias , workdir , pid , stderr ))
571+ if self :grep_log (' Segmentation fault$' , math.huge ) then
572+ error ((' Segmentation fault during process termination (alias: %s, workdir: %s, pid: %d)' )
573+ :format (self .alias , workdir , pid ))
580574 end
581- if stderr : find (' LeakSanitizer' ) then
582- error ((' Memory leak during process execution (alias: %s, workdir: %s, pid: %s)\n %s ' )
583- :format (self .alias , workdir , pid , stderr ))
575+ if self : grep_log (' LeakSanitizer: detected memory leaks$ ' , math.huge ) then
576+ error ((' Memory leak during process execution (alias: %s, workdir: %s, pid: %s)' )
577+ :format (self .alias , workdir , pid ))
584578 end
585579 log .info (' Process of server %q (pid: %d) killed' , self .alias , self .process .pid )
586580 self .process = nil
869863--
870864
871865--- Search a string pattern in the server's log file.
872- -- If the server has crashed, `opts.filename` is required.
873866--
874867-- @string pattern String pattern to search in the server's log file.
875868-- @number[opt] bytes_num Number of bytes to read from the server's log file.
@@ -878,21 +871,13 @@ end
878871-- pattern is found, which means that the server was restarted.
879872-- Defaults to `true`.
880873-- @string[opt] opts.filename Path to the server's log file.
881- -- Defaults to `box.cfg .log`.
874+ -- Defaults to `<workdir>/<alias> .log`.
882875-- @return string|nil
883876function Server :grep_log (pattern , bytes_num , opts )
884877 local options = opts or {}
885878 local reset = options .reset or true
886879
887- -- `box.cfg.log` can contain not only the path to the log file.
888- -- When unified logging mode is on, `box.cfg.log` is as follows:
889- --
890- -- | tee ${TARANTOOL_WORKDIR}/${TARANTOOL_ALIAS}.log
891- --
892- -- Therefore, we set `_G.box_cfg_log_file` in server_instance.lua which
893- -- contains the log file path: ${TARANTOOL_WORKDIR}/${TARANTOOL_ALIAS}.log.
894- local filename = options .filename or self :exec (function ()
895- return rawget (_G , ' box_cfg_log_file' ) or box .cfg .log end )
880+ local filename = options .filename or self .log_file
896881 local file = fio .open (filename , {' O_RDONLY' , ' O_NONBLOCK' })
897882
898883 log .info (' Trying to grep %q in server\' s log file %s' , pattern , filename )
0 commit comments