MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / main

Method main

programs/server/Server.cpp:1187–3520  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1185#endif
1186
1187int Server::main(const std::vector<std::string> & /*args*/)
1188try
1189{
1190#if USE_SSH && defined(OS_LINUX)
1191 ::ssh::LibSSHInitializer::instance();
1192 ::ssh::libsshLogger::initialize();
1193#endif
1194
1195 Stopwatch startup_watch;
1196 Poco::Logger * log = &logger();
1197
1198 const size_t physical_server_memory = getMemoryAmount();
1199
1200 LOG_INFO(
1201 log,
1202 "Available RAM: {}; logical cores: {}; used cores: {}.",
1203 formatReadableSizeWithBinarySuffix(physical_server_memory),
1204 std::thread::hardware_concurrency(),
1205 getNumberOfCPUCoresToUse() // on ARM processors it can show only enabled at current moment cores
1206 );
1207
1208#if defined(__x86_64__)
1209 String cpu_info;
1210#define COLLECT_FLAG(X) \
1211 if (CPU::have##X()) \
1212 { \
1213 if (!cpu_info.empty()) \
1214 cpu_info += ", "; \
1215 cpu_info += #X; \
1216 }
1217
1218 CPU_ID_ENUMERATE(COLLECT_FLAG)
1219#undef COLLECT_FLAG
1220
1221 LOG_INFO(log, "Available CPU instruction sets: {}", cpu_info);
1222#endif
1223
1224 ServerSettings server_settings;
1225 server_settings.loadSettingsFromConfig(config());
1226
1227#if defined(OS_LINUX)
1228 std::string executable_path = getExecutablePath();
1229 /// Remap before creating other threads to prevent crashes
1230 if (server_settings[ServerSetting::remap_executable])
1231 {
1232 LOG_DEBUG(log, "Will remap executable in memory.");
1233 size_t size = remapExecutable();
1234 LOG_DEBUG(log, "The code ({}) in memory has been successfully remapped.", ReadableSize(size));
1235 }
1236
1237 if (server_settings[ServerSetting::mlock_executable])
1238 {
1239 size_t min_physical_server_memory_to_mlock = server_settings[ServerSetting::mlock_executable_min_total_memory_amount_bytes];
1240 if (physical_server_memory >= min_physical_server_memory_to_mlock)
1241 {
1242 if (hasLinuxCapability(CAP_IPC_LOCK))
1243 {
1244 try

Callers

nothing calls this directly

Calls 15

initializeFunction · 0.85
loggerFunction · 0.85
getMemoryAmountFunction · 0.85
getNumberOfCPUCoresToUseFunction · 0.85
getExecutablePathFunction · 0.85
remapExecutableFunction · 0.85
ReadableSizeClass · 0.85
hasLinuxCapabilityFunction · 0.85
getMappedAreaFunction · 0.85
errnoToStringFunction · 0.85
verifySetupFunction · 0.85

Tested by

no test coverage detected