Skip to content

Commit

Permalink
fix compilation
Browse files Browse the repository at this point in the history
Signed-off-by: hjiang <[email protected]>
  • Loading branch information
dentiny committed Nov 27, 2024
1 parent ea19f0a commit 7c1c266
Show file tree
Hide file tree
Showing 15 changed files with 57 additions and 34 deletions.
3 changes: 2 additions & 1 deletion python/ray/includes/global_state_accessor.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ cdef extern from * namespace "ray::gcs" nogil:
ray::RayLog::ShutDownRayLog,
"ray_init",
ray::RayLogLevel::WARNING,
"" /* log_dir */);
"" /* log_dir */,
"" /*log_file */);
RedisClientOptions options(host, port, password, use_ssl);
Expand Down
3 changes: 2 additions & 1 deletion src/ray/common/test/ray_syncer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,8 @@ int main(int argc, char **argv) {
ray::RayLog::ShutDownRayLog,
argv[0],
ray::RayLogLevel::INFO,
/*log_dir=*/"");
/*log_dir=*/"",
/*log_file=*/"");
ray::RayLog::InstallFailureSignalHandler(argv[0]);
ray::RayLog::InstallTerminateHandler();

Expand Down
3 changes: 2 additions & 1 deletion src/ray/core_worker/test/actor_creator_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ int main(int argc, char **argv) {
ray::RayLog::ShutDownRayLog,
argv[0],
ray::RayLogLevel::INFO,
/*log_dir=*/"");
/*log_dir=*/"",
/*log_file=*/"");
ray::RayLog::InstallFailureSignalHandler(argv[0]);
return RUN_ALL_TESTS();
}
3 changes: 2 additions & 1 deletion src/ray/core_worker/test/direct_actor_transport_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,8 @@ int main(int argc, char **argv) {
ray::RayLog::ShutDownRayLog,
argv[0],
ray::RayLogLevel::INFO,
/*log_dir=*/"");
/*log_dir=*/"",
/*log_file=*/"");
ray::RayLog::InstallFailureSignalHandler(argv[0]);
return RUN_ALL_TESTS();
}
3 changes: 2 additions & 1 deletion src/ray/gcs/gcs_client/test/gcs_client_reconnection_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,8 @@ int main(int argc, char **argv) {
ray::RayLog::ShutDownRayLog,
argv[0],
ray::RayLogLevel::INFO,
/*log_dir=*/"");
/*log_dir=*/"",
/*log_file=*/"");
::testing::InitGoogleTest(&argc, argv);
RAY_CHECK(argc == 3);
ray::TEST_REDIS_SERVER_EXEC_PATH = argv[1];
Expand Down
3 changes: 2 additions & 1 deletion src/ray/gcs/gcs_client/test/gcs_client_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,8 @@ int main(int argc, char **argv) {
ray::RayLog::ShutDownRayLog,
argv[0],
ray::RayLogLevel::INFO,
/*log_dir=*/"");
/*log_dir=*/"",
/*log_file=*/"");
::testing::InitGoogleTest(&argc, argv);
RAY_CHECK(argc == 3);
ray::TEST_REDIS_SERVER_EXEC_PATH = argv[1];
Expand Down
3 changes: 2 additions & 1 deletion src/ray/gcs/gcs_client/test/global_state_accessor_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,8 @@ int main(int argc, char **argv) {
ray::RayLog::ShutDownRayLog,
argv[0],
ray::RayLogLevel::INFO,
/*log_dir=*/"");
/*log_dir=*/"",
/*log_file=*/"");
::testing::InitGoogleTest(&argc, argv);
RAY_CHECK(argc == 3);
ray::TEST_REDIS_SERVER_EXEC_PATH = argv[1];
Expand Down
25 changes: 16 additions & 9 deletions src/ray/gcs/gcs_server/gcs_server_main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include <cstdlib>
#include <iostream>
#include <limits>
#include <cstdlib>

#include "gflags/gflags.h"
#include "ray/common/ray_config.h"
Expand Down Expand Up @@ -44,19 +44,26 @@ DEFINE_string(ray_commit, "", "The commit hash of Ray.");
namespace {
// GCS server output filename.
constexpr std::string_view kGcsServerLog = "gcs_server.out";
} // namespace
} // namespace

int main(int argc, char *argv[]) {
gflags::ParseCommandLineFlags(&argc, &argv, true);

// Backward compatibility notes:
// Due to historical reason, GCS server flushes all logging and stdout/stderr to a single file called `gcs_server.out`.
// To keep backward compatibility at best effort, we use the same filename as output, and disable log rotation by default.
const int64_t log_rotation_max_size = FLAGS_log_rotation_size <= 0 ? std::numeric_limits<int64_t>::max() : FLAGS_log_rotation_size;
RAY_CHECK_EQ(setenv("RAY_ROTATION_MAX_BYTES", std::to_string(log_rotation_max_size), /*overwrite=*/1));
const std::string log_file = FLAGS_log_dir.empty() ? kGcsServerLog.data() : absl::StrFormat("%s/%s", FLAGS_log_dir, kGcsServerLog);
// TODO(hjiang): For the current implementation, we assume all logging are managed by spdlog, the caveat is there could be
// there's writing to stdout/stderr as well. The final solution is implement self-customized sink for spdlog, and redirect
// Due to historical reason, GCS server flushes all logging and stdout/stderr to a
// single file called `gcs_server.out`. To keep backward compatibility at best effort,
// we use the same filename as output, and disable log rotation by default.
const int64_t log_rotation_max_size = FLAGS_log_rotation_size <= 0
? std::numeric_limits<int64_t>::max()
: FLAGS_log_rotation_size;
RAY_CHECK_EQ(setenv(
"RAY_ROTATION_MAX_BYTES", std::to_string(log_rotation_max_size), /*overwrite=*/1));
const std::string log_file =
FLAGS_log_dir.empty() ? kGcsServerLog.data()
: absl::StrFormat("%s/%s", FLAGS_log_dir, kGcsServerLog);
// TODO(hjiang): For the current implementation, we assume all logging are managed by
// spdlog, the caveat is there could be there's writing to stdout/stderr as well. The
// final solution is implement self-customized sink for spdlog, and redirect
// stderr/stdout to the file descritor. Hold until it's confirmed necessary.

InitShutdownRAII ray_log_shutdown_raii(ray::RayLog::StartRayLog,
Expand Down
3 changes: 2 additions & 1 deletion src/ray/gcs/store_client/test/redis_store_client_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,8 @@ int main(int argc, char **argv) {
ray::RayLog::ShutDownRayLog,
argv[0],
ray::RayLogLevel::INFO,
/*log_dir=*/"");
/*log_dir=*/"",
/*log_file=*/"");
::testing::InitGoogleTest(&argc, argv);
RAY_CHECK(argc == 3);
ray::TEST_REDIS_SERVER_EXEC_PATH = argv[1];
Expand Down
3 changes: 2 additions & 1 deletion src/ray/gcs/test/asio_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ int main(int argc, char **argv) {
ray::RayLog::ShutDownRayLog,
argv[0],
ray::RayLogLevel::INFO,
/*log_dir=*/"");
/*log_dir=*/"",
/*log_file=*/"");
::testing::InitGoogleTest(&argc, argv);
RAY_CHECK(argc == 3);
ray::TEST_REDIS_SERVER_EXEC_PATH = argv[1];
Expand Down
3 changes: 2 additions & 1 deletion src/ray/raylet/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ int main(int argc, char *argv[]) {
ray::RayLog::ShutDownRayLog,
argv[0],
ray::RayLogLevel::INFO,
/*log_dir=*/"");
/*log_dir=*/"",
/*log_file=*/"");
ray::RayLog::InstallFailureSignalHandler(argv[0]);
ray::RayLog::InstallTerminateHandler();

Expand Down
3 changes: 2 additions & 1 deletion src/ray/raylet/worker_pool_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2161,7 +2161,8 @@ int main(int argc, char **argv) {
[]() { ray::RayLog::ShutDownRayLog(); },
argv[0],
ray::RayLogLevel::INFO,
/*log_dir=*/"");
/*log_dir=*/"",
/*log_file=*/"");
::testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
21 changes: 11 additions & 10 deletions src/ray/util/logging.cc
Original file line number Diff line number Diff line change
Expand Up @@ -311,16 +311,18 @@ void RayLog::InitLogFormat() {
}
}

/*static*/ std::string RayLog::GetLogOutputFilename(const std::string& log_dir, const std::string& log_file, const std::string& app_name) {
/*static*/ std::string RayLog::GetLogOutputFilename(const std::string &log_dir,
const std::string &log_file,
const std::string &app_name) {
if (!log_file.empty()) {
return log_file;
}
if (!log_dir.empty()) {
#ifdef _WIN32
int pid = _getpid();
#else
pid_t pid = getpid();
#endif
#ifdef _WIN32
int pid = _getpid();
#else
pid_t pid = getpid();
#endif

return JoinPaths(log_dir, absl::StrFormat("%s_%d.log", app_name, pid));
}
Expand Down Expand Up @@ -352,7 +354,8 @@ void RayLog::StartRayLog(const std::string &app_name,
}
}

const auto log_output_fname = GetLogOutputFilename(log_dir, log_file, app_name_without_path);
const auto log_output_fname =
GetLogOutputFilename(log_dir, log_file, app_name_without_path);
if (!log_output_fname.empty()) {
// Reset log pattern and level and we assume a log file can be rotated with
// 10 files in max size 512M by default.
Expand Down Expand Up @@ -382,9 +385,7 @@ void RayLog::StartRayLog(const std::string &app_name,
spdlog::drop(RayLog::GetLoggerName());
}
auto file_sink = std::make_shared<spdlog::sinks::rotating_file_sink_mt>(
log_output_fname,
log_rotation_max_size_,
log_rotation_file_num_);
log_output_fname, log_rotation_max_size_, log_rotation_file_num_);
file_sink->set_level(level);
sinks[0] = std::move(file_sink);
} else {
Expand Down
9 changes: 6 additions & 3 deletions src/ray/util/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,9 @@ class RayLog {
/// \param severity_threshold Logging threshold for the program.
/// \param log_dir Logging output directory name.
/// \param log_file Logging output file name.
/// Both [log_dir] and [log_file] are used to determine log output filename; if both empty, the log won't output to file, but to stdout.
/// If both set, [log_file] has higher priority than [log_dir].
/// Both [log_dir] and [log_file] are used to determine log output filename; if both
/// empty, the log won't output to file, but to stdout. If both set, [log_file] has
/// higher priority than [log_dir].
static void StartRayLog(const std::string &appName,
RayLogLevel severity_threshold = RayLogLevel::INFO,
const std::string &log_dir = "",
Expand Down Expand Up @@ -310,7 +311,9 @@ class RayLog {
const std::vector<FatalLogCallback> &expose_log_callbacks);

/// Get log outout filename.
static std::string GetLogOutputFilename(const std::string& log_dir, const std::string& log_file, const std::string& app_name);
static std::string GetLogOutputFilename(const std::string &log_dir,
const std::string &log_file,
const std::string &app_name);

template <typename T>
RayLog &operator<<(const T &t) {
Expand Down
3 changes: 2 additions & 1 deletion src/ray/util/tests/signal_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ int main(int argc, char **argv) {
ray::RayLog::ShutDownRayLog,
argv[0],
ray::RayLogLevel::INFO,
/*log_dir=*/"");
/*log_dir=*/"",
/*log_file=*/"");
ray::RayLog::InstallFailureSignalHandler(argv[0]);
::testing::InitGoogleTest(&argc, argv);
int failed = RUN_ALL_TESTS();
Expand Down

0 comments on commit 7c1c266

Please sign in to comment.