sapling/eden/fs/monitor/LogFile.cpp
Adam Simpkins 4f7fd33e29 add a new process to monitor EdenFS
Summary:
Add a simple new wrapper daemon to manage the edenfs daemon.  This is intended
to provide a few different features:

- Perform log rotation for EdenFS's output and the output of any of its
  spawned children processes.
- Help schedule restarts of EdenFS when the system looks idle.
- Provide a single process for the system to manage across graceful EdenFS
  restarts, to make management slightly simpler.

This initial commit does not perform graceful restarts yet, but has the basic
daemon management and log rotation present.

Reviewed By: wez

Differential Revision: D19588700

fbshipit-source-id: bba41c9f7efeb4417753c1d48dd72cf6d191f0c3
2020-01-31 13:22:26 -08:00

32 lines
718 B
C++

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
#include "eden/fs/monitor/LogFile.h"
#include <fcntl.h>
#include <folly/FileUtil.h>
#include <folly/logging/xlog.h>
namespace facebook {
namespace eden {
LogFile::LogFile(const AbsolutePath& path)
: log_(path.c_str(), O_CREAT | O_WRONLY | O_APPEND, 0644) {}
int LogFile::write(const void* buffer, size_t size) {
// TODO: Rotate the log file if necessary
auto bytesWritten = folly::writeFull(log_.fd(), buffer, size);
if (bytesWritten == -1) {
return errno;
}
return 0;
}
} // namespace eden
} // namespace facebook