rm unused fn
This commit is contained in:
parent
d182544c99
commit
f2dbe9c087
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "download.h"
|
#include "download.h"
|
||||||
|
|
||||||
#include <cpp-httplib/httplib.h>
|
#include <cpp-httplib/httplib.h> // TODO: remove this once we use HTTP client from download.h
|
||||||
#include <sheredom/subprocess.h>
|
#include <sheredom/subprocess.h>
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
@ -23,55 +23,8 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__APPLE__) && defined(__MACH__)
|
|
||||||
// macOS: use _NSGetExecutablePath to get the executable path
|
|
||||||
#include <mach-o/dyld.h>
|
|
||||||
#include <limits.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define CMD_EXIT "exit"
|
#define CMD_EXIT "exit"
|
||||||
|
|
||||||
static std::filesystem::path get_server_exec_path() {
|
|
||||||
#if defined(_WIN32)
|
|
||||||
wchar_t buf[32768] = { 0 }; // Large buffer to handle long paths
|
|
||||||
DWORD len = GetModuleFileNameW(nullptr, buf, _countof(buf));
|
|
||||||
if (len == 0 || len >= _countof(buf)) {
|
|
||||||
throw std::runtime_error("GetModuleFileNameW failed or path too long");
|
|
||||||
}
|
|
||||||
return std::filesystem::path(buf);
|
|
||||||
#elif defined(__APPLE__) && defined(__MACH__)
|
|
||||||
char small_path[PATH_MAX];
|
|
||||||
uint32_t size = sizeof(small_path);
|
|
||||||
|
|
||||||
if (_NSGetExecutablePath(small_path, &size) == 0) {
|
|
||||||
// resolve any symlinks to get absolute path
|
|
||||||
try {
|
|
||||||
return std::filesystem::canonical(std::filesystem::path(small_path));
|
|
||||||
} catch (...) {
|
|
||||||
return std::filesystem::path(small_path);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// buffer was too small, allocate required size and call again
|
|
||||||
std::vector<char> buf(size);
|
|
||||||
if (_NSGetExecutablePath(buf.data(), &size) == 0) {
|
|
||||||
try {
|
|
||||||
return std::filesystem::canonical(std::filesystem::path(buf.data()));
|
|
||||||
} catch (...) {
|
|
||||||
return std::filesystem::path(buf.data());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw std::runtime_error("_NSGetExecutablePath failed after buffer resize");
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
char path[FILENAME_MAX];
|
|
||||||
ssize_t count = readlink("/proc/self/exe", path, FILENAME_MAX);
|
|
||||||
if (count <= 0) {
|
|
||||||
throw std::runtime_error("failed to resolve /proc/self/exe");
|
|
||||||
}
|
|
||||||
return std::filesystem::path(std::string(path, count));
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
struct local_model {
|
struct local_model {
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string path;
|
std::string path;
|
||||||
|
|
@ -364,7 +317,6 @@ void server_models::load(const std::string & name, bool auto_load) {
|
||||||
|
|
||||||
inst.subproc = std::make_shared<subprocess_s>();
|
inst.subproc = std::make_shared<subprocess_s>();
|
||||||
{
|
{
|
||||||
//std::string exec_path = get_server_exec_path().string();
|
|
||||||
SRV_INF("spawning server instance with name=%s on port %d\n", inst.meta.name.c_str(), inst.meta.port);
|
SRV_INF("spawning server instance with name=%s on port %d\n", inst.meta.name.c_str(), inst.meta.port);
|
||||||
|
|
||||||
std::vector<std::string> child_args;
|
std::vector<std::string> child_args;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue