[COMMIT osv-apps master] apps: add nginx from host example

4 views
Skip to first unread message

Commit Bot

unread,
May 25, 2021, 12:29:24 AM5/25/21
to osv...@googlegroups.com, Waldemar Kozaczuk
From: Waldemar Kozaczuk <jwkoz...@gmail.com>
Committer: Waldemar Kozaczuk <jwkoz...@gmail.com>
Branch: master

apps: add nginx from host example

It looks like nginx has 'daemon off;' option that allows
us to run it in a mode that does not require any fork.

This patch adds an example that pulls nginx binary along with
any dependencies from Linux host. The configuration has been
tested with version 1.18.0 and 1.20.0 with binaries taken from
Ubuntu and Fedora hosts.

Signed-off-by: Waldemar Kozaczuk <jwkoz...@gmail.com>

---
diff --git a/nginx-from-host/Makefile b/nginx-from-host/Makefile
--- a/nginx-from-host/Makefile
+++ b/nginx-from-host/Makefile
@@ -0,0 +1,14 @@
+.PHONY: module clean
+
+SRC = $(shell readlink -f ../..)
+
+nginx_exe_path = $(shell realpath $$(which nginx))
+
+module:
+ $(SRC)/scripts/manifest_from_host.sh $(nginx_exe_path) > usr.manifest
+ echo '/nginx.conf: $${MODULE_DIR}/nginx.conf' >> usr.manifest
+ echo '/var/log/nginx: ->/tmp' >> usr.manifest
+ echo '/var/lib/nginx: ->/tmp' >> usr.manifest
+
+clean:
+ rm -rf usr.manifest
diff --git a/nginx-from-host/module.py b/nginx-from-host/module.py
--- a/nginx-from-host/module.py
+++ b/nginx-from-host/module.py
@@ -0,0 +1,3 @@
+from osv.modules import api
+
+default = api.run('/nginx -c /nginx.conf')
diff --git a/nginx-from-host/nginx.conf b/nginx-from-host/nginx.conf
--- a/nginx-from-host/nginx.conf
+++ b/nginx-from-host/nginx.conf
@@ -0,0 +1,39 @@
+worker_processes 1;
+daemon off;
+master_process off;
+
+pid /tmp/bob.pid;
+
+error_log stderr error;
+
+events {
+ worker_connections 1024;
+}
+
+http {
+ access_log off;
+ #error_log off;
+
+ proxy_temp_path /tmp/proxy_temp 1 2;
+ client_body_temp_path /tmp/client_body_temp;
+ fastcgi_temp_path /tmp/fastcgi_temp 1 2;
+ uwsgi_temp_path /tmp/uwsgi_temp 1 2;
+ scgi_temp_path /tmp/scgi_temp 1 2;
+
+ sendfile on;
+ tcp_nopush on;
+
+ # Default keepalive param values
+ #keepalive_requests 100;
+ # Long keepalive to avoid/reduce preblems with TCP port resue
+ # See https://github.com/cloudius-systems/osv/issues/889
+ keepalive_requests 1000000000;
+
+ server {
+ listen 8000;
+
+ location / {
+ root /;
+ }
+ }
+}
diff --git a/nginx-from-host/test.sh b/nginx-from-host/test.sh
--- a/nginx-from-host/test.sh
+++ b/nginx-from-host/test.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+THIS_DIR=$(readlink -f $(dirname $0))
+CMDLINE=$($THIS_DIR/../cmdline.sh $THIS_DIR)
+
+$THIS_DIR/../../scripts/tests/test_http_app.py \
+ -e "$CMDLINE" \
+ --http_path "/nginx.conf" \
+ --guest_port 8000 \
+ --host_port 8000 \
+ --line 'epoll_wait' \
+ --http_line 'worker_connections' \
+ --count 10000
Reply all
Reply to author
Forward
0 new messages