MCPcopy Create free account
hub / github.com/ByConity/ByConity / mainEntryClickHouseInstall

Function mainEntryClickHouseInstall

programs/install/Install.cpp:106–504  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104
105
106int mainEntryClickHouseInstall(int argc, char ** argv)
107{
108 po::options_description desc;
109 desc.add_options()
110 ("help,h", "produce help message")
111 ("prefix", po::value<std::string>()->default_value(""), "prefix for all paths")
112 ("binary-path", po::value<std::string>()->default_value("/usr/bin"), "where to install binaries")
113 ("config-path", po::value<std::string>()->default_value("/etc/byconity-server"), "where to install configs")
114 ("log-path", po::value<std::string>()->default_value("/var/log/byconity-server"), "where to create log directory")
115 ("data-path", po::value<std::string>()->default_value("/var/lib/byconity-server"), "directory for data")
116 ("disk-path", po::value<std::string>()->default_value("/var/lib/byconity-server/server_local_disk/data/0/"), "directory for local data parts")
117 ("pid-path", po::value<std::string>()->default_value("/var/run/byconity-server"), "directory for pid file")
118 ("user", po::value<std::string>()->default_value("clickhouse"), "clickhouse user to create")
119 ("group", po::value<std::string>()->default_value("clickhouse"), "clickhouse group to create")
120 ;
121
122 po::variables_map options;
123 po::store(po::parse_command_line(argc, argv, desc), options);
124
125 if (options.count("help"))
126 {
127 std::cout << "Usage: "
128 << (getuid() == 0 ? "" : "sudo ")
129 << argv[0]
130 << " install [options]\n";
131 std::cout << desc << '\n';
132 }
133
134 try
135 {
136 /// We need to copy binary to the binary directory.
137 /// The binary is currently run. We need to obtain its path from procfs (on Linux).
138
139#if defined(OS_DARWIN)
140 uint32_t path_length = 0;
141 _NSGetExecutablePath(nullptr, &path_length);
142 if (path_length <= 1)
143 Exception(ErrorCodes::FILE_DOESNT_EXIST, "Cannot obtain path to the binary");
144
145 std::string path(path_length, std::string::value_type());
146 auto res = _NSGetExecutablePath(&path[0], &path_length);
147 if (res != 0)
148 Exception(ErrorCodes::FILE_DOESNT_EXIST, "Cannot obtain path to the binary");
149
150 fs::path binary_self_path(path);
151#else
152 fs::path binary_self_path = "/proc/self/exe";
153#endif
154
155 if (!fs::exists(binary_self_path))
156 throw Exception(ErrorCodes::FILE_DOESNT_EXIST, "Cannot obtain path to the binary from {}, file doesn't exist",
157 binary_self_path.string());
158
159 fs::path binary_self_canonical_path = fs::canonical(binary_self_path);
160
161 /// Copy binary to the destination directory.
162
163 /// TODO An option to link instead of copy - useful for developers.

Callers

nothing calls this directly

Calls 15

storeFunction · 0.85
filesEqualFunction · 0.85
throwFromErrnoFunction · 0.85
ReadableSizeClass · 0.85
renameFunction · 0.85
removeFunction · 0.85
executeScriptFunction · 0.85
getCurrentExceptionCodeFunction · 0.85
getuidFunction · 0.50
ExceptionClass · 0.50
existsFunction · 0.50

Tested by

no test coverage detected