@@ -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,16 @@ 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 ))
580- 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 ))
571+ -- Check the log file for crash and memory leak reports.
572+ if fio .path .exists (self .log_file ) then
573+ if self :grep_log (' Segmentation fault$' , math.huge ) then
574+ error ((' Segmentation fault during process termination (alias: %s, workdir: %s, pid: %d)' )
575+ :format (self .alias , workdir , pid ))
576+ end
577+ if self :grep_log (' LeakSanitizer: detected memory leaks$' , math.huge ) then
578+ error ((' Memory leak during process execution (alias: %s, workdir: %s, pid: %s)' )
579+ :format (self .alias , workdir , pid ))
580+ end
584581 end
585582 log .info (' Process of server %q (pid: %d) killed' , self .alias , self .process .pid )
586583 self .process = nil
869866--
870867
871868--- Search a string pattern in the server's log file.
872- -- If the server has crashed, `opts.filename` is required.
873869--
874870-- @string pattern String pattern to search in the server's log file.
875871-- @number[opt] bytes_num Number of bytes to read from the server's log file.
@@ -878,21 +874,12 @@ end
878874-- pattern is found, which means that the server was restarted.
879875-- Defaults to `true`.
880876-- @string[opt] opts.filename Path to the server's log file.
881- -- Defaults to `box.cfg .log`.
877+ -- Defaults to `<workdir>/<alias> .log`.
882878-- @return string|nil
883879function Server :grep_log (pattern , bytes_num , opts )
884880 local options = opts or {}
885881 local reset = options .reset or true
886-
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 )
882+ local filename = options .filename or self .log_file
896883 local file = fio .open (filename , {' O_RDONLY' , ' O_NONBLOCK' })
897884
898885 log .info (' Trying to grep %q in server\' s log file %s' , pattern , filename )
0 commit comments