2 Commits
Author SHA1 Message Date
SuspiciousActivity 79af2ece97 1.0.6 2026-10-03 17:18:47 +02:00
SuspiciousActivity c2d4e01d0b add signal handlers 2026-10-03 17:18:30 +02:00
3 changed files with 10 additions and 2 deletions

No files matched your search

+1 -1
View File
@@ -25,4 +25,4 @@ WORKDIR /app
COPY --from=builder /app/build-docker/fasttext_lid_server . COPY --from=builder /app/build-docker/fasttext_lid_server .
RUN curl --remote-name https://dl.fbaipublicfiles.com/fasttext/supervised-models/lid.176.bin RUN curl --remote-name https://dl.fbaipublicfiles.com/fasttext/supervised-models/lid.176.bin
CMD ["sh", "-c", "./fasttext_lid_server ${MODEL_FILE:-lid.176.bin} ${PORT:-8080}"] CMD ["sh", "-c", "exec ./fasttext_lid_server ${MODEL_FILE:-lid.176.bin} ${PORT:-8080}"]
+8
View File
@@ -3,6 +3,9 @@
#include <string> #include <string>
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <csignal>
httplib::Server *g_svr = nullptr;
std::string stripLabel(const std::string &label) { std::string stripLabel(const std::string &label) {
const std::string prefix = "__label__"; const std::string prefix = "__label__";
@@ -59,8 +62,13 @@ int main(int argc, char *argv[]) {
res.set_content(result, "application/json"); res.set_content(result, "application/json");
}); });
g_svr = &svr;
std::signal(SIGINT, [](int) { if (g_svr) g_svr->stop(); });
std::signal(SIGTERM, [](int) { if (g_svr) g_svr->stop(); });
auto port = std::stoi(argv[2]); auto port = std::stoi(argv[2]);
std::cout << "Starting server on port " << port << std::endl; std::cout << "Starting server on port " << port << std::endl;
svr.listen("0.0.0.0", port); svr.listen("0.0.0.0", port);
std::cout << "Server stopped" << std::endl;
return 0; return 0;
} }
+1 -1
View File
@@ -1,7 +1,7 @@
#!/bin/sh #!/bin/sh
set -e set -e
version=1.0.5 version=1.0.6
image_name="suspiciousactivity/fasttext-lid-server" image_name="suspiciousactivity/fasttext-lid-server"
# Check git status # Check git status