2016-01-17 13:34:36 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
2020-07-04 13:54:24 +00:00
|
|
|
#include <functional>
|
2016-01-17 13:34:36 +00:00
|
|
|
#include <boost/noncopyable.hpp>
|
|
|
|
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
2020-07-04 13:54:24 +00:00
|
|
|
class WriteBuffer;
|
|
|
|
|
2016-01-17 13:34:36 +00:00
|
|
|
|
2017-03-09 00:56:38 +00:00
|
|
|
/** Provides that no more than one server works with one data directory.
|
2016-01-17 13:34:36 +00:00
|
|
|
*/
|
|
|
|
class StatusFile : private boost::noncopyable
|
|
|
|
{
|
|
|
|
public:
|
2020-07-04 13:54:24 +00:00
|
|
|
using FillFunction = std::function<void(WriteBuffer&)>;
|
|
|
|
|
|
|
|
StatusFile(std::string path_, FillFunction fill_);
|
2016-01-17 13:34:36 +00:00
|
|
|
~StatusFile();
|
|
|
|
|
2020-07-04 13:54:24 +00:00
|
|
|
/// You can use one of these functions to fill the file or provide your own.
|
|
|
|
static FillFunction write_pid;
|
|
|
|
static FillFunction write_full_info;
|
|
|
|
|
2016-01-17 13:34:36 +00:00
|
|
|
private:
|
|
|
|
const std::string path;
|
2020-07-04 13:54:24 +00:00
|
|
|
FillFunction fill;
|
2016-01-17 13:34:36 +00:00
|
|
|
int fd = -1;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|