Skip to content

Commit

Permalink
fix logging
Browse files Browse the repository at this point in the history
Signed-off-by: dentiny <[email protected]>
  • Loading branch information
dentiny committed Feb 11, 2025
1 parent a51031d commit 2f3a943
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 22 deletions.
1 change: 1 addition & 0 deletions bazel/BUILD.redis
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ make(
args = [
"BUILD_TLS=yes",
"-s",
"-j$$(nproc)",
],
copts = [
"-DLUA_USE_MKSTEMP",
Expand Down
2 changes: 1 addition & 1 deletion bazel/ray.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def copy_to_workspace(name, srcs, dstdir = ""):
dstdir = "." + ("/" + dstdir.replace("\\", "/")).rstrip("/") + "/",
),
local = 1,
tags = ["no-cache"],
# tags = ["no-cache"],
)

def native_java_binary(module_name, name, native_binary_name):
Expand Down
57 changes: 36 additions & 21 deletions src/ray/core_worker/core_worker_process.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,28 +81,43 @@ CoreWorkerProcessImpl::CoreWorkerProcessImpl(const CoreWorkerOptions &options)
? ComputeDriverIdFromJob(options_.job_id)
: WorkerID::FromRandom()) {
if (options_.enable_logging) {
std::stringstream app_name_ss;
app_name_ss << LanguageString(options_.language) << "-core-"
<< WorkerTypeString(options_.worker_type);
if (!worker_id_.IsNil()) {
app_name_ss << "-" << worker_id_;
// Setup logging for worker system logging.
{
std::stringstream app_name_ss;
app_name_ss << LanguageString(options_.language) << "-core-"
<< WorkerTypeString(options_.worker_type);
if (!worker_id_.IsNil()) {
app_name_ss << "-" << worker_id_;
}
const std::string app_name = app_name_ss.str();
const std::string log_filepath =
RayLog::GetLogFilepathFromDirectory(options_.log_dir, /*app_name=*/app_name);
RayLog::StartRayLog(app_name,
RayLogLevel::INFO,
log_filepath,
ray::RayLog::GetRayLogRotationMaxBytesOrDefault(),
ray::RayLog::GetRayLogRotationBackupCountOrDefault());
}

// Setup logging for worker application logging.
{
std::stringstream app_name_ss;
app_name_ss << WorkerTypeString(options_.worker_type);
if (!worker_id_.IsNil()) {
app_name_ss << "-" << worker_id_;
}
const std::string app_name = app_name_ss.str();
const std::string log_filepath =
RayLog::GetLogFilepathFromDirectory(options_.log_dir, /*app_name=*/app_name);

ray::StreamRedirectionOption stdout_redirection_options;
stdout_redirection_options.file_path = log_filepath;
stdout_redirection_options.rotation_max_size =
ray::RayLog::GetRayLogRotationMaxBytesOrDefault();
stdout_redirection_options.rotation_max_file_count =
ray::RayLog::GetRayLogRotationBackupCountOrDefault();
ray::RedirectStdout(stdout_redirection_options);
}
const std::string app_name = app_name_ss.str();
const std::string log_filepath =
RayLog::GetLogFilepathFromDirectory(options_.log_dir, /*app_name=*/app_name);
RayLog::StartRayLog(app_name,
RayLogLevel::INFO,
log_filepath,
ray::RayLog::GetRayLogRotationMaxBytesOrDefault(),
ray::RayLog::GetRayLogRotationBackupCountOrDefault());

ray::StreamRedirectionOption stdout_redirection_options;
stdout_redirection_options.file_path = log_filepath;
stdout_redirection_options.rotation_max_size =
ray::RayLog::GetRayLogRotationMaxBytesOrDefault();
stdout_redirection_options.rotation_max_file_count =
ray::RayLog::GetRayLogRotationBackupCountOrDefault();
ray::RedirectStdout(stdout_redirection_options);

if (options_.install_failure_signal_handler) {
// Core worker is loaded as a dynamic library from Python or other languages.
Expand Down

0 comments on commit 2f3a943

Please sign in to comment.