Update media_server_app.cpp
This commit is contained in:
parent
3d8ee493a9
commit
6c4db875ac
@ -3,6 +3,12 @@
|
||||
#include <iostream>
|
||||
#include <signal.h>
|
||||
#include <string>
|
||||
#include <cstdlib>
|
||||
|
||||
#if defined(__linux__)
|
||||
#include <limits.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#include "graph_manager.h"
|
||||
#include "utils/simple_json.h"
|
||||
@ -13,8 +19,28 @@ namespace {
|
||||
|
||||
GraphManager* g_manager = nullptr;
|
||||
|
||||
std::string ResolvePluginDir() {
|
||||
if (const char* env = std::getenv("RK_PLUGIN_DIR")) {
|
||||
return std::string(env);
|
||||
}
|
||||
|
||||
#if defined(__linux__)
|
||||
char path[PATH_MAX] = {0};
|
||||
ssize_t len = readlink("/proc/self/exe", path, sizeof(path) - 1);
|
||||
if (len > 0) {
|
||||
std::string exe_path(path, static_cast<size_t>(len));
|
||||
auto pos = exe_path.find_last_of('/');
|
||||
if (pos != std::string::npos) {
|
||||
return exe_path.substr(0, pos) + "/plugins";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return std::string("plugins");
|
||||
}
|
||||
|
||||
GraphManager& GetManager() {
|
||||
static GraphManager mgr;
|
||||
static GraphManager mgr(ResolvePluginDir());
|
||||
return mgr;
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user