mirror of
https://github.com/wassname/ray.git
synced 2026-06-28 15:22:56 +08:00
Log to terminal if glog is also doing so (#7868)
This commit is contained in:
+11
-15
@@ -349,25 +349,21 @@ class Node:
|
||||
raise FileExistsError(errno.EEXIST,
|
||||
"No usable temporary filename found")
|
||||
|
||||
def new_log_files(self, name, redirect_output=True):
|
||||
def new_log_files(self, name):
|
||||
"""Generate partially randomized filenames for log files.
|
||||
|
||||
Args:
|
||||
name (str): descriptive string for this log file.
|
||||
redirect_output (bool): True if files should be generated for
|
||||
logging stdout and stderr and false if stdout and stderr
|
||||
should not be redirected.
|
||||
If it is None, it will use the "redirect_output" Ray parameter.
|
||||
|
||||
Returns:
|
||||
If redirect_output is true, this will return a tuple of two
|
||||
file handles. The first is for redirecting stdout and the
|
||||
second is for redirecting stderr.
|
||||
If redirect_output is false, this will return a tuple
|
||||
of two None objects.
|
||||
A tuple of two file handles for redirecting (stdout, stderr).
|
||||
"""
|
||||
redirect_output = self._ray_params.redirect_output
|
||||
|
||||
if redirect_output is None:
|
||||
redirect_output = self._ray_params.redirect_output
|
||||
# Make the default behavior match that of glog.
|
||||
redirect_output = os.getenv("GLOG_logtostderr") != "1"
|
||||
|
||||
if not redirect_output:
|
||||
return None, None
|
||||
|
||||
@@ -471,7 +467,7 @@ class Node:
|
||||
|
||||
def start_reporter(self):
|
||||
"""Start the reporter."""
|
||||
stdout_file, stderr_file = self.new_log_files("reporter", True)
|
||||
stdout_file, stderr_file = self.new_log_files("reporter")
|
||||
process_info = ray.services.start_reporter(
|
||||
self.redis_address,
|
||||
stdout_file=stdout_file,
|
||||
@@ -492,7 +488,7 @@ class Node:
|
||||
fail to start the webui. Otherwise it will print a warning if
|
||||
we fail to start the webui.
|
||||
"""
|
||||
stdout_file, stderr_file = self.new_log_files("dashboard", True)
|
||||
stdout_file, stderr_file = self.new_log_files("dashboard")
|
||||
self._webui_url, process_info = ray.services.start_dashboard(
|
||||
require_webui,
|
||||
self._ray_params.webui_host,
|
||||
@@ -580,8 +576,8 @@ class Node:
|
||||
|
||||
def new_worker_redirected_log_file(self, worker_id):
|
||||
"""Create new logging files for workers to redirect its output."""
|
||||
worker_stdout_file, worker_stderr_file = (self.new_log_files(
|
||||
"worker-" + ray.utils.binary_to_hex(worker_id), True))
|
||||
worker_stdout_file, worker_stderr_file = (
|
||||
self.new_log_files("worker-" + ray.utils.binary_to_hex(worker_id)))
|
||||
return worker_stdout_file, worker_stderr_file
|
||||
|
||||
def start_worker(self):
|
||||
|
||||
@@ -939,7 +939,9 @@ def _start_redis_instance(executable,
|
||||
if counter == num_retries:
|
||||
raise RuntimeError("Couldn't start Redis. "
|
||||
"Check log files: {} {}".format(
|
||||
stdout_file.name, stderr_file.name))
|
||||
stdout_file.name if stdout_file is not None else
|
||||
"<stdout>", stderr_file.name
|
||||
if stdout_file is not None else "<stderr>"))
|
||||
|
||||
# Create a Redis client just for configuring Redis.
|
||||
redis_client = redis.StrictRedis(
|
||||
|
||||
Reference in New Issue
Block a user