Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions frameworks/swerver/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM debian:trixie AS build

RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates curl xz-utils git libssl-dev dpkg-dev pkg-config python3 \
ca-certificates curl xz-utils git libssl-dev zlib1g-dev dpkg-dev pkg-config python3 \
&& rm -rf /var/lib/apt/lists/*

# Install Zig 0.16.0 stable
Expand All @@ -22,7 +22,7 @@ RUN set -eux; \

# Clone swerver library
WORKDIR /src
RUN git clone --depth 1 --branch v0.1.0-alpha.6 \
RUN git clone --depth 1 --branch v0.1.0-alpha.10 \
https://github.com/justinGrosvenor/swerver.git .

# Symlink OpenSSL for Zig's linker
Expand All @@ -46,9 +46,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
COPY --from=build /src/httparena/zig-out/bin/swerver-httparena /usr/local/bin/swerver
COPY config-h1.json /etc/swerver/config-h1.json
COPY config-tls.json /etc/swerver/config-tls.json
COPY config-tls-h1.json /etc/swerver/config-tls-h1.json
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
RUN chmod +x /usr/local/bin/entrypoint.sh

EXPOSE 8080 8443/tcp 8443/udp
EXPOSE 8080 8081 8443/tcp 8443/udp

CMD ["/usr/local/bin/entrypoint.sh"]
2 changes: 1 addition & 1 deletion frameworks/swerver/build.zig.zon
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.{
.name = .swerver_httparena,
.version = "0.1.0-alpha.6",
.version = "0.1.0-alpha.10",
.fingerprint = 0xd44040f91e2c7045,
.minimum_zig_version = "0.16.0",
.paths = .{
Expand Down
4 changes: 1 addition & 3 deletions frameworks/swerver/config-h1.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
},
"buffer_pool": {
"buffer_size": 65536,
"buffer_count": 1024,
"body_buffer_size": 22020096,
"body_buffer_count": 2
"buffer_count": 1024
},
"http2": {
"max_streams": 256,
Expand Down
22 changes: 22 additions & 0 deletions frameworks/swerver/config-tls-h1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"server": {
"address": "0.0.0.0",
"port": 8081,
"max_connections": 512,
"static_root": "/data/static",
"workers": 0,
"disable_middleware": true
},
"buffer_pool": {
"buffer_size": 65536,
"buffer_count": 1024
},
"tls": {
"cert_path": "/certs/server.crt",
"key_path": "/certs/server.key"
},
"http2": {
"max_streams": 256,
"initial_window_size": 1048576
}
}
8 changes: 6 additions & 2 deletions frameworks/swerver/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,18 @@ H1_PID=$!
/usr/local/bin/swerver --config /etc/swerver/config-tls.json &
TLS_PID=$!

/usr/local/bin/swerver --config /etc/swerver/config-tls-h1.json &
TLS_H1_PID=$!

shutdown() {
kill "$H1_PID" "$TLS_PID" 2>/dev/null || true
kill "$H1_PID" "$TLS_PID" "$TLS_H1_PID" 2>/dev/null || true
wait "$H1_PID" 2>/dev/null || true
wait "$TLS_PID" 2>/dev/null || true
wait "$TLS_H1_PID" 2>/dev/null || true
exit 0
}
trap shutdown TERM INT

wait -n "$H1_PID" "$TLS_PID"
wait -n "$H1_PID" "$TLS_PID" "$TLS_H1_PID"
shutdown
exit 1
2 changes: 1 addition & 1 deletion frameworks/swerver/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ pub fn main(init: std.process.Init) !void {
try app_router.get("/baseline2", handleBaseline);
try app_router.post("/baseline2", handleBaseline);
try app_router.get("/json/:count", handleJson);
try app_router.post("/upload", handleUpload);
try app_router.postDiscard("/upload", handleUpload);

if (cfg.workers != 1) {
var master = try swerver.Master.init(allocator, cfg, app_router, null);
Expand Down
2 changes: 2 additions & 0 deletions frameworks/swerver/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
"pipelined",
"limited-conn",
"json",
"json-tls",
"upload",
"static",
"baseline-h2",
"static-h2",
Expand Down