Mongrel2 is an application, language, and network architecture agnostic

web server that focuses on web applications using modern browser
technologies.

OK landry@ a while back
This commit is contained in:
jeremy 2011-04-01 22:28:02 +00:00
parent 13924d3bf0
commit 3557f0c5b9
10 changed files with 377 additions and 0 deletions

42
www/mongrel2/Makefile Normal file
View File

@ -0,0 +1,42 @@
# $OpenBSD: Makefile,v 1.1.1.1 2011/04/01 22:28:02 jeremy Exp $
# Some assembly required
ONLY_FOR_ARCH = i386 amd64
COMMENT = language agnostic asynchronous web server
DISTNAME = mongrel2-1.5
CATEGORIES = www
HOMEPAGE = http://mongrel2.org/
# BSD, 3 clause
PERMIT_PACKAGE_CDROM = Yes
PERMIT_PACKAGE_FTP = Yes
PERMIT_DISTFILES_CDROM = Yes
PERMIT_DISTFILES_FTP = Yes
MASTER_SITES = http://mongrel2.org/static/downloads/
EXTRACT_SUFX = .tar.bz2
WANTLIB += c pthread sqlite3 zmq
LIB_DEPENDS = net/zeromq \
databases/sqlite3
USE_GMAKE = Yes
ALL_TARGET = openbsd
EXAMPLE_DIR = ${PREFIX}/share/examples/mongrel2
pre-configure:
${SUBST_CMD} ${WRKSRC}/Makefile
post-install:
${INSTALL_DATA_DIR} ${EXAMPLE_DIR}
tar -cf - -C ${WRKSRC}/examples . | tar -xf - -C ${EXAMPLE_DIR}
chown -R ${SHAREOWN}:${SHAREGRP} ${EXAMPLE_DIR}
REGRESS_TARGET = tests
.include <bsd.port.mk>

5
www/mongrel2/distinfo Normal file
View File

@ -0,0 +1,5 @@
MD5 (mongrel2-1.5.tar.bz2) = tpn/x++SKtfXA/zTmol5EA==
RMD160 (mongrel2-1.5.tar.bz2) = crwmKxVWs+1qCmBYXA1/QoXX7rI=
SHA1 (mongrel2-1.5.tar.bz2) = 8XnBFwJVbta/EP4JK6ek4c3OLGc=
SHA256 (mongrel2-1.5.tar.bz2) = dCkENkynUXIJj4KNVOTYdpTDgeChZgNVfcXz4CGGizM=
SIZE (mongrel2-1.5.tar.bz2) = 733493

View File

@ -0,0 +1,41 @@
$OpenBSD: patch-Makefile,v 1.1.1.1 2011/04/01 22:28:02 jeremy Exp $
--- Makefile.orig Sun Jan 9 15:18:13 2011
+++ Makefile Fri Feb 25 08:40:22 2011
@@ -11,7 +11,7 @@ LIB_OBJ=$(filter-out src/mongrel2.o,${OBJECTS})
TEST_SRC=$(wildcard tests/*.c)
TESTS=$(patsubst %.c,%,${TEST_SRC})
-all: bin/mongrel2 tests m2sh
+all: bin/mongrel2 m2sh
dev: CFLAGS=-g -Wall -Isrc -Wall -Wextra $(OPTFLAGS)
dev: all
@@ -43,6 +43,8 @@ pristine: clean
${MAKE} -C tools/m2sh pristine
.PHONY: tests
+tests: OPTFLAGS=-I${LOCALBASE}/include
+tests: OPTLIBS=-L${LOCALBASE}/lib -pthread
tests: build/libm2.a tests/config.sqlite ${TESTS}
sh ./tests/runtests.sh
@@ -66,7 +68,7 @@ check:
m2sh:
${MAKE} OPTFLAGS="${OPTFLAGS}" OPTLIBS="${OPTLIBS}" -C tools/m2sh all
-install: all install-bin install-m2sh
+install: install-bin install-m2sh
install-bin:
install -d $(PREFIX)/bin/
@@ -113,8 +115,8 @@ freebsd: OPTFLAGS=-I/usr/local/include
freebsd: OPTLIBS=-L/usr/local/lib -pthread
freebsd: all
-openbsd: OPTFLAGS=-l/usr/local/include
-openbsd: OPTLIBS=-L/usr/local/lib -pthread
+openbsd: OPTFLAGS=-I${LOCALBASE}/include
+openbsd: OPTLIBS=-L${LOCALBASE}/lib -pthread
openbsd: all
solaris: OPTFLAGS=-I/usr/local/include

View File

@ -0,0 +1,57 @@
$OpenBSD: patch-src_bsd_specific_c,v 1.1.1.1 2011/04/01 22:28:02 jeremy Exp $
--- src/bsd_specific.c.orig Sun Jan 9 15:18:13 2011
+++ src/bsd_specific.c Fri Feb 25 08:29:53 2011
@@ -71,10 +71,52 @@ error:
#else
+extern int fdrecv(int fd, void *buf, int n);
+extern int fdsend(int fd, void *buf, int n);
+
+#define BSD_SENDFILE_BUF_SIZE 16384
+#include <unistd.h>
+
/** For the BSDs without sendfile like open and net.**/
int bsd_sendfile(int out_fd, int in_fd, off_t *offset, size_t count) {
- return -1;
+ char buf[BSD_SENDFILE_BUF_SIZE];
+ int tot, cur, rem, sent;
+ int ret = -1;
+ off_t orig_offset;
+
+ if (offset != NULL) {
+ orig_offset = lseek(in_fd, 0, SEEK_CUR);
+ check(orig_offset >= 0, "lseek failure when determining current position");
+ check(lseek(in_fd, *offset, SEEK_SET) >= 0, "lseek failure when setting new position");
+ }
+
+ for (tot = 0, rem = count, cur = rem; cur != 0 && tot < count; tot += cur, rem -= cur) {
+ if (rem >= BSD_SENDFILE_BUF_SIZE) {
+ cur = BSD_SENDFILE_BUF_SIZE;
+ } else {
+ cur = rem;
+ }
+
+ cur = fdread(in_fd, buf, cur);
+ check(cur >= 0, "Internal sendfile emulation failed: fdread: %i", cur);
+
+ if (cur != 0) {
+ sent = fdwrite(out_fd, buf, cur);
+ check(sent == cur, "Internal sendfile emulation failed: fdread: %i, fdwrite: %i", cur, sent);
+ }
+ }
+
+ ret = tot;
+
+error:
+ if (offset != NULL) {
+ if (ret != -1) {
+ *offset += tot;
+ }
+ lseek(in_fd, orig_offset, SEEK_SET);
+ }
+ return ret;
}
#endif

View File

@ -0,0 +1,12 @@
$OpenBSD: patch-src_io_h,v 1.1.1.1 2011/04/01 22:28:02 jeremy Exp $
--- src/io.h.orig Thu Feb 24 11:30:31 2011
+++ src/io.h Thu Feb 24 11:31:51 2011
@@ -86,7 +86,7 @@ int IOBuf_stream_file(IOBuf *buf, int fd, int len);
#define IOBuf_fd(I) ((I)->fd)
-#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)
+#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
#define Dir_send bsd_sendfile
#else
#define Dir_send sendfile

View File

@ -0,0 +1,21 @@
$OpenBSD: patch-src_task_asm_S,v 1.1.1.1 2011/04/01 22:28:02 jeremy Exp $
--- src/task/asm.S.orig Thu Feb 24 13:03:43 2011
+++ src/task/asm.S Thu Feb 24 13:05:01 2011
@@ -6,10 +6,16 @@
#define GET getmcontext
#endif
-#if defined(__OpenBSD__) && defined(__i386__)
+#if defined(__OpenBSD__)
+#if defined(__i386__)
#define NEEDX86CONTEXT 1
#define SET setmcontext
#define GET getmcontext
+#elif defined(__x86_64__)
+#define NEEDAMD64CONTEXT 1
+#define SET setmcontext
+#define GET getmcontext
+#endif
#endif
#if defined(__APPLE__)

View File

@ -0,0 +1,19 @@
$OpenBSD: patch-src_task_context_c,v 1.1.1.1 2011/04/01 22:28:02 jeremy Exp $
--- src/task/context.c.orig Sun Jan 9 15:18:13 2011
+++ src/task/context.c Thu Feb 24 12:36:11 2011
@@ -20,9 +20,14 @@
#define NEEDSWAPCONTEXT
#endif
-#if defined(__OpenBSD__) && defined(__i386__)
+#if defined(__OpenBSD__)
+#if defined(__i386__)
#define NEEDX86MAKECONTEXT
#define NEEDSWAPCONTEXT
+#elif defined(__x86_64__)
+#define NEEDAMD64MAKECONTEXT
+#define NEEDSWAPCONTEXT
+#endif
#endif
#if defined(__linux__) && defined(__arm__)

View File

@ -0,0 +1,12 @@
$OpenBSD: patch-src_task_taskimpl_h,v 1.1.1.1 2011/04/01 22:28:02 jeremy Exp $
--- src/task/taskimpl.h.orig Thu Feb 24 12:21:50 2011
+++ src/task/taskimpl.h Thu Feb 24 12:22:11 2011
@@ -88,6 +88,8 @@ extern void makecontext(ucontext_t*, void(*)
# define ucontext_t libthread_ucontext_t
# if defined __i386__
# include "386-ucontext.h"
+# elif defined(__x86_64__)
+# include "amd64-ucontext.h"
# else
# include "power-ucontext.h"
# endif

30
www/mongrel2/pkg/DESCR Normal file
View File

@ -0,0 +1,30 @@
Mongrel2 is an application, language, and network architecture agnostic
web server that focuses on web applications using modern browser
technologies.
Features
* Language Agnostic with a simple backend protocol supporting Ruby,
Ruby through Rack, Python, Python (Brubeck), C++, C, PHP, Haskell,
Common Lisp, Perl, Perl (AnyEvent), .NET, Clojure, Java, and Lua all
written by Mongrel2 fans.
* Modern Browser Friendly designed to handle HTTP, Flash XMLSockets, or
WebSockets, Long Polling on the same socket transparently.
* ZeroMQ Enabled as well as HTTP proxy support so it works with what
you have already while giving you new super powers.
* Network Architecture Agnostic so you can carve your operations up
anyway that reduces costs.
* N:M Messaging Patterns means you can have any N handlers answer to
any M browsers arbitrarily, but still easy to do plain
request/response.
* Automation Loving Configs that are easily accessible via any
programming language with an Model-View-Controller design.
* Modern Internal Design using the Mongrel 1 HTTP parser powering many
big companies with a proven security track record, event based I/O,
fast coroutines to handle that I/O, and smart reasonable defaults
with zero configuration needed usually.
* Documented, Documented, Documented We document everything in a well
written manual that shows you how to use every feature.
* BSD Licensed and all with a BSD 3-clause license.
* Tir: An official framework written in Lua that shows how to use
Mongrel2.

138
www/mongrel2/pkg/PLIST Normal file
View File

@ -0,0 +1,138 @@
@comment $OpenBSD: PLIST,v 1.1.1.1 2011/04/01 22:28:02 jeremy Exp $
@bin bin/m2sh
@bin bin/mongrel2
share/examples/mongrel2/
share/examples/mongrel2/bbs/
share/examples/mongrel2/bbs/bbs.lua
share/examples/mongrel2/bbs/client.py
share/examples/mongrel2/bbs/config.lua
share/examples/mongrel2/bbs/db.lua
share/examples/mongrel2/bbs/engine.lua
share/examples/mongrel2/bbs/html/
share/examples/mongrel2/bbs/html/app.js
share/examples/mongrel2/bbs/html/bbs.js
share/examples/mongrel2/bbs/html/flash/
share/examples/mongrel2/bbs/html/flash/JsSocket.hx
share/examples/mongrel2/bbs/html/flash/Makefile
share/examples/mongrel2/bbs/html/flash/jsSocket.as
share/examples/mongrel2/bbs/html/flash/jsSocket.swf
share/examples/mongrel2/bbs/html/flash/jsSocket2.swf
share/examples/mongrel2/bbs/html/fsm.js
share/examples/mongrel2/bbs/html/index.html
share/examples/mongrel2/bbs/html/js/
share/examples/mongrel2/bbs/html/js/jsSocket.js
share/examples/mongrel2/bbs/html/js/jsonStringify.js
share/examples/mongrel2/bbs/html/reset.css
share/examples/mongrel2/bbs/html/site.css
share/examples/mongrel2/bbs/html/text.css
share/examples/mongrel2/bbs/mongrel2.conf
share/examples/mongrel2/bbs/strict.lua
share/examples/mongrel2/bbs/ui.lua
share/examples/mongrel2/chat/
share/examples/mongrel2/chat/chat.py
share/examples/mongrel2/chat/idiots
share/examples/mongrel2/chat/static/
share/examples/mongrel2/chat/static/960.css
share/examples/mongrel2/chat/static/app.js
share/examples/mongrel2/chat/static/chat.js
share/examples/mongrel2/chat/static/flash/
share/examples/mongrel2/chat/static/flash/JsSocket.hx
share/examples/mongrel2/chat/static/flash/Makefile
share/examples/mongrel2/chat/static/flash/jsSocket.as
share/examples/mongrel2/chat/static/flash/jsSocket.swf
share/examples/mongrel2/chat/static/flash/jsSocket2.swf
share/examples/mongrel2/chat/static/fsm.js
share/examples/mongrel2/chat/static/index.html
share/examples/mongrel2/chat/static/js/
share/examples/mongrel2/chat/static/js/jsSocket.js
share/examples/mongrel2/chat/static/js/jsonStringify.js
share/examples/mongrel2/chat/static/reset.css
share/examples/mongrel2/chat/static/site.css
share/examples/mongrel2/chat/static/text.css
share/examples/mongrel2/chat/www.py
share/examples/mongrel2/configs/
share/examples/mongrel2/configs/any.conf
share/examples/mongrel2/configs/complex.conf
share/examples/mongrel2/configs/mongrel2.conf
share/examples/mongrel2/configs/multi.conf
share/examples/mongrel2/configs/sample.conf
share/examples/mongrel2/http_0mq/
share/examples/mongrel2/http_0mq/http.py
share/examples/mongrel2/http_0mq/upload.py
share/examples/mongrel2/http_0mq/xml.py
share/examples/mongrel2/kegogi/
share/examples/mongrel2/kegogi/Makefile
share/examples/mongrel2/kegogi/lemon.c
share/examples/mongrel2/kegogi/lempar.c
share/examples/mongrel2/kegogi/src/
share/examples/mongrel2/kegogi/src/fuzzrnd.c
share/examples/mongrel2/kegogi/src/fuzzrnd.h
share/examples/mongrel2/kegogi/src/httpclient.c
share/examples/mongrel2/kegogi/src/httpclient.h
share/examples/mongrel2/kegogi/src/kegogi.c
share/examples/mongrel2/kegogi/src/kegogi.h
share/examples/mongrel2/kegogi/src/kegogi_lexer.c
share/examples/mongrel2/kegogi/src/kegogi_lexer.rl
share/examples/mongrel2/kegogi/src/kegogi_parser.c
share/examples/mongrel2/kegogi/src/kegogi_parser.h
share/examples/mongrel2/kegogi/src/kegogi_parser.y
share/examples/mongrel2/kegogi/src/kegogi_parser_extra.c
share/examples/mongrel2/kegogi/src/kegogi_tokens.c
share/examples/mongrel2/kegogi/src/kegogi_tokens.h
share/examples/mongrel2/kegogi/src/param.c
share/examples/mongrel2/kegogi/src/param.h
share/examples/mongrel2/kegogi/tests/
share/examples/mongrel2/kegogi/tests/googletest.txt
share/examples/mongrel2/mp3stream/
share/examples/mongrel2/mp3stream/handler.py
share/examples/mongrel2/mp3stream/mp3stream.py
share/examples/mongrel2/mp3stream/stream_conf.py
share/examples/mongrel2/procer/
share/examples/mongrel2/procer/Makefile
share/examples/mongrel2/procer/procer.c
share/examples/mongrel2/procer/procer.h
share/examples/mongrel2/procer/profile.c
share/examples/mongrel2/procer/rampart.c
share/examples/mongrel2/python/
share/examples/mongrel2/python/bin/
share/examples/mongrel2/python/bin/m2shpy
share/examples/mongrel2/python/mongrel2/
share/examples/mongrel2/python/mongrel2/__init__.py
share/examples/mongrel2/python/mongrel2/config/
share/examples/mongrel2/python/mongrel2/config/__init__.py
share/examples/mongrel2/python/mongrel2/config/args.py
share/examples/mongrel2/python/mongrel2/config/commands.py
share/examples/mongrel2/python/mongrel2/config/model.py
share/examples/mongrel2/python/mongrel2/config/rc.py
share/examples/mongrel2/python/mongrel2/handler.py
share/examples/mongrel2/python/mongrel2/request.py
share/examples/mongrel2/python/mongrel2/sql/
share/examples/mongrel2/python/mongrel2/sql/config.sql
share/examples/mongrel2/python/setup.py
share/examples/mongrel2/python/tests/
share/examples/mongrel2/python/tests/__init__.py
share/examples/mongrel2/python/tests/composite_conf.py
share/examples/mongrel2/python/tests/mongrel2_org.py
share/examples/mongrel2/python/tests/sample_conf.py
share/examples/mongrel2/python/tests/two_servers.py
share/examples/mongrel2/tornado/
share/examples/mongrel2/tornado/README
share/examples/mongrel2/tornado/auth_demo.py
share/examples/mongrel2/tornado/authdemo.py
share/examples/mongrel2/zcov/
share/examples/mongrel2/zcov/LICENSE.txt
share/examples/mongrel2/zcov/README.txt
share/examples/mongrel2/zcov/bin/
share/examples/mongrel2/zcov/bin/zcov-genhtml
share/examples/mongrel2/zcov/bin/zcov-merge
share/examples/mongrel2/zcov/bin/zcov-scan
share/examples/mongrel2/zcov/bin/zcov-summarize
share/examples/mongrel2/zcov/setup.py
share/examples/mongrel2/zcov/zcov/
share/examples/mongrel2/zcov/zcov/GCovGroup.py
share/examples/mongrel2/zcov/zcov/GCovParser.py
share/examples/mongrel2/zcov/zcov/data/
share/examples/mongrel2/zcov/zcov/data/js/
share/examples/mongrel2/zcov/zcov/data/js/sorttable.js
share/examples/mongrel2/zcov/zcov/data/js/sourceview.js
share/examples/mongrel2/zcov/zcov/data/style.css