| 60 | << " OpenAI-style streaming: speech stream_format=sse|audio, transcription stream=true\n" |
| 61 | << " POST /v1/tasks/run\n"; |
| 62 | } |
| 63 | |
| 64 | } // namespace |
| 65 | |
| 66 | int main(int argc, char ** argv) { |
| 67 | try { |
| 68 | if (has_arg(argc, argv, "--help") || has_arg(argc, argv, "-h")) { |
| 69 | print_help(); |
| 70 | return 0; |
| 71 | } |
| 72 | const auto config_path = arg_value(argc, argv, "--config"); |
| 73 | if (!config_path.has_value()) { |
| 74 | throw std::runtime_error("missing required --config argument"); |
| 75 | } |
| 76 | const auto log_file = arg_value(argc, argv, "--log-file"); |
| 77 | engine::debug::configure_logging(engine::debug::LoggingConfig{ |
| 78 | has_arg(argc, argv, "--log") || log_file.has_value(), |
| 79 | log_file, |
| 80 | }); |
| 81 | std::signal(SIGINT, request_shutdown); |
| 82 | std::signal(SIGTERM, request_shutdown); |
| 83 | #ifdef SIGPIPE |
| 84 | // Writing to a socket whose peer has already disconnected (for example a |
| 85 | // client that closed an SSE/chunked stream early) would otherwise deliver |
| 86 | // SIGPIPE and terminate the whole server. Ignore it so the failed send |
| 87 | // surfaces as an EPIPE error on that single request thread, which |
| 88 | // handle_client already unwinds cleanly, instead of taking the process down. |
| 89 | std::signal(SIGPIPE, SIG_IGN); |
| 90 | #endif |
| 91 | |
| 92 | auto config = minitts::server::load_server_config(*config_path); |
| 93 | if (const auto host = arg_value(argc, argv, "--host")) { |
| 94 | config.host = *host; |
| 95 | } |
| 96 | if (const auto port = arg_value(argc, argv, "--port")) { |
| 97 | config.port = std::stoi(*port); |
| 98 | } |
| 99 | if (const auto backend = arg_value(argc, argv, "--backend")) { |
| 100 | config.backend = minitts::server::parse_server_backend(*backend); |
| 101 | } |
| 102 | if (const auto device = arg_value(argc, argv, "--device")) { |
| 103 | config.device = std::stoi(*device); |
| 104 | } |
| 105 | if (const auto threads = arg_value(argc, argv, "--threads")) { |
| 106 | config.threads = std::stoi(*threads); |
| 107 | } |
| 108 | if (const auto busy_timeout = arg_value(argc, argv, "--busy-timeout-ms")) { |
| 109 | config.busy_timeout_ms = std::stoi(*busy_timeout); |
| 110 | } |
nothing calls this directly
no test coverage detected