Print certain resource limits on server startup
This commit is contained in:
parent
9acd10fa4c
commit
8fdf7bfb04
|
@ -30,6 +30,7 @@
|
||||||
|
|
||||||
#ifdef PLATFORM_LINUX
|
#ifdef PLATFORM_LINUX
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
#include <sys/resource.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
@ -568,6 +569,40 @@ void ServiceSetup::loadConfigFiles(bool doFirstTimeSetup)
|
||||||
cerr << Phrases::SubMessage << "Ccache directory: " << building.ccacheDir << Phrases::End;
|
cerr << Phrases::SubMessage << "Ccache directory: " << building.ccacheDir << Phrases::End;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef PLATFORM_LINUX
|
||||||
|
static void printLimitValue(auto value, bool size)
|
||||||
|
{
|
||||||
|
if (value == RLIM_INFINITY) {
|
||||||
|
cerr << "infinity";
|
||||||
|
} else if (size) {
|
||||||
|
cerr << dataSizeToString(value);
|
||||||
|
} else {
|
||||||
|
cerr << value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void printLimit(auto field, std::string_view fieldName, bool size = false)
|
||||||
|
{
|
||||||
|
auto limit = rlimit();
|
||||||
|
getrlimit(field, &limit);
|
||||||
|
cerr << Phrases::SubMessage << fieldName << ": ";
|
||||||
|
printLimitValue(limit.rlim_cur, size);
|
||||||
|
cerr << " / ";
|
||||||
|
printLimitValue(limit.rlim_max, size);
|
||||||
|
cerr << Phrases::End;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void ServiceSetup::printLimits()
|
||||||
|
{
|
||||||
|
#ifdef PLATFORM_LINUX
|
||||||
|
cerr << Phrases::InfoMessage << "Limits (soft / hard):" << Phrases::End;
|
||||||
|
printLimit(RLIMIT_NOFILE, "NOFILE (Number of open files)");
|
||||||
|
printLimit(RLIMIT_MEMLOCK, "MEMLOCK (Locked-in-memory address space)", true);
|
||||||
|
printLimit(RLIMIT_LOCKS, "LOCKS (Maximum number of file locks)");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void ServiceSetup::printDatabases()
|
void ServiceSetup::printDatabases()
|
||||||
{
|
{
|
||||||
cerr << Phrases::SuccessMessage << "Found " << config.databases.size() << " databases:" << Phrases::End;
|
cerr << Phrases::SuccessMessage << "Found " << config.databases.size() << " databases:" << Phrases::End;
|
||||||
|
@ -659,6 +694,7 @@ int ServiceSetup::run()
|
||||||
#ifndef CPP_UTILITIES_DEBUG_BUILD
|
#ifndef CPP_UTILITIES_DEBUG_BUILD
|
||||||
try {
|
try {
|
||||||
#endif
|
#endif
|
||||||
|
printLimits();
|
||||||
loadConfigFiles(true);
|
loadConfigFiles(true);
|
||||||
config.discardDatabases();
|
config.discardDatabases();
|
||||||
config.loadAllPackages(building.loadFilesDbs, building.forceLoadingDbs);
|
config.loadAllPackages(building.loadFilesDbs, building.forceLoadingDbs);
|
||||||
|
|
|
@ -48,6 +48,7 @@ struct LIBREPOMGR_EXPORT ServiceSetup : public LibPkg::Lockable {
|
||||||
std::size_t packageCacheLimit = 1000;
|
std::size_t packageCacheLimit = 1000;
|
||||||
|
|
||||||
void loadConfigFiles(bool doFirstTimeSetup);
|
void loadConfigFiles(bool doFirstTimeSetup);
|
||||||
|
void printLimits();
|
||||||
void printDatabases();
|
void printDatabases();
|
||||||
std::string_view cacheFilePath() const;
|
std::string_view cacheFilePath() const;
|
||||||
void restoreState();
|
void restoreState();
|
||||||
|
|
Loading…
Reference in New Issue