MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / main

Function main

app/server/main.cpp:62–107  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60std::pair<std::string, std::string> parse_key_value_arg(const std::string & text, const std::string & name) {
61 const auto eq = text.find('=');
62 if (eq == std::string::npos || eq == 0) {
63 throw std::runtime_error(name + " must be key=value");
64 }
65 return {text.substr(0, eq), text.substr(eq + 1)};
66}
67
68std::filesystem::path executable_directory(const char * argv0) {
69 if (argv0 == nullptr || *argv0 == '\0') {
70 return std::filesystem::current_path();
71 }
72 std::error_code ec;
73 auto path = std::filesystem::absolute(std::filesystem::path(argv0), ec);
74 if (ec) {
75 return std::filesystem::current_path();
76 }
77 path = path.lexically_normal();
78 if (std::filesystem::is_regular_file(path, ec)) {
79 return path.parent_path();
80 }
81 return std::filesystem::current_path();
82}
83
84void print_help() {
85 std::cout
86 << "audiocpp_server [--config <server.json>] [--ui] [--host <ip>] [--port <port>] [--backend <backend>]\n"
87 << " [--device <id>] [--list-devices] [--threads <n>] [--busy-timeout-ms <ms>]\n"
88 << " [--max-loaded-models <n>] [--idle-unload-ms <ms>] [--min-free-memory-mb <mb>]\n"
89 << " [--model-spec-override <json-or-directory>] [--voice-dir <directory>]\n"
90 << " [--frontend-listener <name>] [--frontend-option key=value]\n"
91 << " [--log] [--log-file <path>]\n"
92 << " [--cors-origins <origins>]\n"
93 << " --version print build version, commit, compiler, platform, and enabled backends\n"
94 << " --ui serve the embedded WebUI\n"
95 << " --no-ui disable the embedded WebUI\n"
96 << " --ui-management allow WebUI model management and downloads; requires\n"
97 << " AUDIOCPP_BUILD_NATIVE_MODEL_MANAGER=ON at build time\n"
98 << " --host <ip> server bind address; default 127.0.0.1\n"
99 << " --port <port> server listening port; default 8080\n"
100 << " --backend cpu|cuda|hip|rocm|vulkan|metal default cuda (rocm is an alias for hip)\n"
101 << " --list-devices list available backend devices and exit\n"
102 << " --busy-timeout-ms <ms> fail a request with 503 when the model has been\n"
103 << " busy this long; default 300000, 0 disables\n"
104 << " --max-loaded-models <n> keep at most n models resident in memory, unloading\n"
105 << " the least recently used idle model first; 1 enforces\n"
106 << " a single loaded model, default 0 (no limit)\n"
107 << " --idle-unload-ms <ms> unload all resident models after this many ms without\n"
108 << " any model load/run; default 0 (disabled), next request\n"
109 << " reloads lazily\n"
110 << " --min-free-memory-mb <mb> refuse a model load unless host and GPU each keep at\n"

Callers

nothing calls this directly

Calls 7

print_helpFunction · 0.85
configure_loggingFunction · 0.85
load_server_configFunction · 0.85
parse_server_backendFunction · 0.85
serve_httpFunction · 0.85
has_argFunction · 0.70
arg_valueFunction · 0.70

Tested by

no test coverage detected