sapling/eden/fs/service/EdenInit.h
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

77 lines
2.1 KiB
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.
*/
#pragma once
/*
* This file contains helper functions related to parsing edenfs command line
* arguments and determining the initial Eden configuration and state directory.
*
* This enables this logic to be shared by the main edenfs process as well as
* other helper tools that need to be able to access the Eden state directory
* and configuration data.
*/
#include <memory>
#include <string>
#include <folly/Conv.h>
#include <folly/portability/GFlags.h>
#include "eden/fs/utils/PathFuncs.h"
DECLARE_bool(foreground);
DECLARE_string(configPath);
DECLARE_string(etcEdenDir);
namespace facebook {
namespace eden {
class EdenConfig;
class UserInfo;
PathComponentPiece getDefaultLogFileName();
AbsolutePath makeDefaultLogDirectory(AbsolutePathPiece edenDir);
std::string getLogPath(AbsolutePathPiece edenDir);
/**
* Get the EdenConfig object.
*
* This processes the command line arguments and config settings to construct
* the EdenConfig. This also determines the location of the Eden state
* directory, which can be obtained by calling EdenConfig::getEdenDir().
* This function will create the Eden state directory on disk if it does not
* already exist.
*/
std::unique_ptr<EdenConfig> getEdenConfig(UserInfo& identity);
/**
* ArgumentError will be thrown by getEdenConfig() for common or expected
* exceptions when trying to set up the Eden config data. This includes issues
* like bad command line arguments or errors creating or finding the expected
* state and config data on disk.
*
* The caller of getEdenConfig() should generally catch ArgumentError exceptions
* and display them nicely to the end user.
*/
class ArgumentError : public std::exception {
public:
template <class... Args>
explicit ArgumentError(Args&&... args)
: message_(folly::to<std::string>(std::forward<Args>(args)...)) {}
const char* what() const noexcept override {
return message_.c_str();
}
private:
std::string message_;
};
} // namespace eden
} // namespace facebook