| 805 | #endif |
| 806 | |
| 807 | void sanityChecks(Server & server, const ServerSettings & server_settings) |
| 808 | { |
| 809 | std::string data_path = getCanonicalPath(String(server_settings[ServerSetting::path]), server.getOriginalWorkingDirectory()); |
| 810 | std::string logs_path = server_settings[ServerSetting::logger_log]; |
| 811 | |
| 812 | if (server.logger().is(Poco::Message::PRIO_TEST)) |
| 813 | server.context()->addOrUpdateWarningMessage( |
| 814 | Context::WarningType::SERVER_LOGGING_LEVEL_TEST, |
| 815 | PreformattedMessage::create( |
| 816 | "Server logging level is set to 'test' and performance is degraded. This cannot be used in production.")); |
| 817 | #if defined(OS_LINUX) |
| 818 | try |
| 819 | { |
| 820 | const std::unordered_set<std::string> fast_clock_sources = { |
| 821 | // ARM clock |
| 822 | "arch_sys_counter", |
| 823 | // KVM guest clock |
| 824 | "kvm-clock", |
| 825 | // X86 clock |
| 826 | "tsc", |
| 827 | }; |
| 828 | const char * filename = "/sys/devices/system/clocksource/clocksource0/current_clocksource"; |
| 829 | if (!fast_clock_sources.contains(readLine(filename))) |
| 830 | server.context()->addOrUpdateWarningMessage( |
| 831 | Context::WarningType::LINUX_FAST_CLOCK_SOURCE_NOT_USED, |
| 832 | PreformattedMessage::create("Linux is not using a fast clock source. Performance can be degraded. Check {}", filename)); |
| 833 | } |
| 834 | catch (const std::exception &) // NOLINT(bugprone-empty-catch) |
| 835 | { |
| 836 | } |
| 837 | |
| 838 | try |
| 839 | { |
| 840 | const char * filename = "/proc/sys/vm/overcommit_memory"; |
| 841 | if (readNumber(filename) == 2) |
| 842 | server.context()->addOrUpdateWarningMessage( |
| 843 | Context::WarningType::LINUX_MEMORY_OVERCOMMIT_DISABLED, |
| 844 | PreformattedMessage::create("Linux memory overcommit is disabled. Check {}", String(filename))); |
| 845 | } |
| 846 | catch (const std::exception &) // NOLINT(bugprone-empty-catch) |
| 847 | { |
| 848 | } |
| 849 | |
| 850 | try |
| 851 | { |
| 852 | const char * filename = "/sys/kernel/mm/transparent_hugepage/enabled"; |
| 853 | if (readLine(filename).find("[always]") != std::string::npos) |
| 854 | server.context()->addOrUpdateWarningMessage( |
| 855 | Context::WarningType::LINUX_TRANSPARENT_HUGEPAGES_SET_TO_ALWAYS, |
| 856 | PreformattedMessage::create("Linux transparent hugepages are set to \"always\". Check {}", String(filename))); |
| 857 | } |
| 858 | catch (const std::exception &) // NOLINT(bugprone-empty-catch) |
| 859 | { |
| 860 | } |
| 861 | |
| 862 | try |
| 863 | { |
| 864 | const char * filename = "/proc/sys/kernel/pid_max"; |
no test coverage detected