mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2025-05-10 01:33:53 +00:00
Fix SIGINT problem in Docker image
This commit is contained in:
parent
4e6055f084
commit
87fab847b8
@ -1,8 +1,7 @@
|
|||||||
FROM ubuntu AS builder
|
FROM yhirose4dockerhub/ubuntu-builder AS builder
|
||||||
WORKDIR /build
|
WORKDIR /build
|
||||||
COPY httplib.h .
|
COPY httplib.h .
|
||||||
COPY docker/main.cc .
|
COPY docker/main.cc .
|
||||||
RUN apt update && apt install g++ -y
|
|
||||||
RUN g++ -std=c++23 -static -o server -O2 -I. -DCPPHTTPLIB_USE_POLL main.cc && strip server
|
RUN g++ -std=c++23 -static -o server -O2 -I. -DCPPHTTPLIB_USE_POLL main.cc && strip server
|
||||||
|
|
||||||
FROM scratch
|
FROM scratch
|
||||||
|
@ -23,6 +23,8 @@ constexpr auto error_html = R"(<html>
|
|||||||
</html>
|
</html>
|
||||||
)";
|
)";
|
||||||
|
|
||||||
|
void sigint_handler(int s) { exit(1); }
|
||||||
|
|
||||||
std::string time_local() {
|
std::string time_local() {
|
||||||
auto p = std::chrono::system_clock::now();
|
auto p = std::chrono::system_clock::now();
|
||||||
auto t = std::chrono::system_clock::to_time_t(p);
|
auto t = std::chrono::system_clock::to_time_t(p);
|
||||||
@ -49,6 +51,8 @@ std::string log(auto &req, auto &res) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, const char **argv) {
|
int main(int argc, const char **argv) {
|
||||||
|
signal(SIGINT, sigint_handler);
|
||||||
|
|
||||||
auto base_dir = "./html";
|
auto base_dir = "./html";
|
||||||
auto host = "0.0.0.0";
|
auto host = "0.0.0.0";
|
||||||
auto port = 80;
|
auto port = 80;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user