22 if (cachePath.empty())
27 cachePath.append(
"/pids/");
30 if (!std::filesystem::exists(dir) && !std::filesystem::create_directories(dir))
32 ARMARX_WARNING_S <<
"Unable to create Cache directory for the ScenarioManager plugin at "
37 std::string filename = cachePath + app->getPackageName() +
"." + app->getScenario()->getName() +
38 "." + app->getName() + (app->getInstanceName().empty() ?
"" :
".") +
39 app->getInstanceName() +
".pids";
41 if (!std::filesystem::exists(filename))
46 std::ifstream input(filename);
58 if (cachePath.empty())
62 ARMARX_WARNING_S <<
"No cache path configured - the pid of " << app->getName()
63 <<
" cannot be persisted, and the application will be reported as "
64 "stopped once its pid is lost.";
68 cachePath.append(
"/pids/");
71 if (!std::filesystem::exists(dir) && !std::filesystem::create_directories(dir))
73 ARMARX_WARNING_S <<
"Unable to create Cache directory for the ScenarioManager plugin at "
77 std::string filename = cachePath + app->getPackageName() +
"." + app->getScenario()->getName() +
78 "." + app->getName() + (app->getInstanceName().empty() ?
"" :
".") +
79 app->getInstanceName() +
".pids";
81 if (app->getPid() == -1)
83 std::filesystem::remove(std::filesystem::path(filename));
87 std::ofstream output(filename);
89 output << app->getPid();
94 ARMARX_WARNING_S <<
"Failed to write the pid of " << app->getName() <<
" to " << filename
95 <<
". The application will be reported as stopped once its pid is lost.";
103 cachePath.append(
"/pids/");
105 std::filesystem::remove_all(std::filesystem::path(cachePath));
void savePid(Data_Structure::ApplicationInstancePtr app)
int loadPid(Data_Structure::ApplicationInstancePtr app)
static std::string GetCachePath()
The base Cache directory of ArmarX.
#define ARMARX_WARNING_S
The logging level for unexpected behaviour, but not a serious problem.
std::shared_ptr< ApplicationInstance > ApplicationInstancePtr
This file offers overloads of toIce() and fromIce() functions for STL container types.
fs::path remove_trailing_separator(fs::path p)