Skip to content

Commit

Permalink
in_http: handle HTTP server setup, custom C headers and config
Browse files Browse the repository at this point in the history
Signed-off-by: Eduardo Silva <eduardo@treasure-data.com>
  • Loading branch information
edsiper committed Jun 12, 2015
1 parent bc2757a commit 613720f
Show file tree
Hide file tree
Showing 8 changed files with 254 additions and 6 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ add_subdirectory(lib/msgpack-0.5.9)
add_subdirectory(lib/jsmn)
if(WITH_IN_HTTP)
set(WITHOUT_BIN 1 CACHE BOOL "Do not build binary")
set(WITHOUT_CONF 1 CACHE BOOL "Skip configuration files")
set(WITHOUT_PLUGINS "auth,cgi,cheetah,dirlisting,fastcgi,logger,mandril,tls")
add_subdirectory(lib/monkey)
else()
Expand Down
46 changes: 46 additions & 0 deletions plugins/in_http/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,49 @@ FLB_PLUGIN(in_http "${src}" "")
target_link_libraries(flb-plugin-in_http
${CMAKE_BINARY_DIR}/library/libmonkey.a
${CMAKE_DL_LIBS})

# Configuration files
# ===================
# Default values for conf/in_http.conf

set(MK_CONF_LISTEN "8080")
set(MK_CONF_WORKERS "1")
set(MK_CONF_TIMEOUT "15")
set(MK_CONF_INDEXFILE "index.html index.htm index.php")
set(MK_CONF_HIDEVERSION "Off")
set(MK_CONF_RESUME "On")
set(MK_CONF_KA "On")
set(MK_CONF_KA_TIMEOUT "5")
set(MK_CONF_KA_MAXREQ "1000")
set(MK_CONF_REQ_SIZE "32")
set(MK_CONF_SYMLINK "Off")
set(MK_CONF_TRANSPORT "liana")
set(MK_CONF_DEFAULT_MIME "text/plain")
set(MK_CONF_FDT "On")
set(MK_CONF_OVERCAPACITY "Resist")

# Virtual Host
# ============
set(MK_VH_SERVERNAME "127.0.0.1")
set(MK_PATH_WWW "${PROJECT_SOURCE_DIR}/lib/monkey/htdocs")
set(IN_HTTP_CONF_PATH "${PROJECT_BINARY_DIR}/conf/")

configure_file(
"in_http_info.h.in"
"${PROJECT_SOURCE_DIR}/plugins/in_http/in_http_info.h"
)

configure_file(
"conf/in_http.conf.in"
"${PROJECT_BINARY_DIR}/conf/in_http.conf"
)

configure_file(
"conf/sites/default.in"
"${PROJECT_BINARY_DIR}/conf/sites/default"
)

configure_file(
"conf/mimetypes.conf.in"
"${PROJECT_BINARY_DIR}/conf/mimetypes.conf"
)
18 changes: 18 additions & 0 deletions plugins/in_http/conf/in_http.conf.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Monkey HTTP Server - Configuration
# ==================================
[SERVER]
Listen @MK_CONF_LISTEN@
Workers @MK_CONF_WORKERS@
Timeout @MK_CONF_TIMEOUT@
PidFile @MK_PATH_PIDFILE@/@MK_CONF_PIDFILE@
Indexfile @MK_CONF_INDEXFILE@
HideVersion @MK_CONF_HIDEVERSION@
Resume @MK_CONF_RESUME@
KeepAlive @MK_CONF_KA@
KeepAliveTimeout @MK_CONF_KA_TIMEOUT@
MaxKeepAliveRequest @MK_CONF_KA_MAXREQ@
MaxRequestSize @MK_CONF_REQ_SIZE@
SymLink @MK_CONF_SYMLINK@
DefaultMimeType @MK_CONF_DEFAULT_MIME@
FDT @MK_CONF_FDT@
OverCapacity @MK_CONF_OVERCAPACITY@
145 changes: 145 additions & 0 deletions plugins/in_http/conf/mimetypes.conf.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
[MIMETYPES]
html text/html
jpg image/jpeg
png image/png
js application/x-javascript
css text/css
xml text/xml
gif image/gif
flv video/x-flv
jpe image/jpeg

deb application/x-debian-package
jpeg image/jpeg
htm text/html
bmp image/bmp
ief image/ief
tiff image/tiff
tif image/tiff
wbmp image/vnd.wap.wbmp
ras image/x-cmu-raster
ico image/x-icon
pnm image/x-portable-anymap
pbm image/x-portable-bitmap
pgm image/x-portable-graymap
ppm image/x-portable-pixmap
rgb image/x-rgb
xbm image/x-xbitmap
xpm image/x-xpixmap
xwd image/x-xwindowdump
svg image/svg+xml
svgz image/svg+xml

json application/json
ez application/andrew-inset
hqx application/mac-binhex40
cpt application/mac-compactpro
doc application/msword
bin application/octet-stream
dms application/octet-stream
lha application/octet-stream
lhz application/octet-stream
exe application/octet-stream
oda application/oda
pdf application/pdf
api application/postscript
eps application/postscript
ps application/postscript
smi application/smil
smil application/smil
mif application/vnd.mif
xls application/vnd.ms-excel
ppt application/vnd.ms-powerpoint
vbxml application/vnd.wap.wbxml
wmlc application/vnd.wap.wmlc
wmlsc application/vnd.wap.wmlscriptc
bcpio application/x-bcpio
vcd application/x-cdlink
pgn application/x-chess-pgn
cpio application/x-cpio
csh application/x-csh
dcr application/x-director
dir application/x-director
dxr application/x-director
dvi application/x-dvi
spl application/x-futuresplash
gtar application/x-gtar
gz application/x-gzip
hdf application/x-hdf
skp application/x-koan
skd application/x-koan
skt application/x-koan
skm application/x-koan
latex application/x-latex
nc application/x-netcdf
cdf application/x-netcdf
sh application/x-sh
shar application/x-shar
swf application/x-shockwave-flash
sit application/x-stuffit
sv4cpio application/x-sv4cpio
sv4crc application/x-sv4crc
tar application/x-tar
tcl application/x-tcl
tex application/x-tex
texinfo application/x-texinfo
texi application/x-texinfo
t application/x-troff
tr application/x-troff
roff application/x-troff
man application/x-troff-man
me application/x-troff-me
ms application/x-troff-ms
untar application/x-ustar
src application/x-wais-source
zip application/zip

au audio/basic
snd audio/basic
mid audio/midi
midi audio/midi
kar audio/midi
mpga audio/mpeg
mp2 audio/mpeg
mp3 audio/mpeg
aif audio/x-aiff
aiff audio/x-aiff
aifc audio/x-aiff
ram audio/x-pn-realaudio
rm audio/x-pn-realaudio
rpm audio/x-pn-realaudio-plugin
ra audio/x-realaudio
wav audio/x-wav

pdb chemical/x-pdb
xyz chemical/x-pdb

igs model/iges
iges model/iges
msh model/mesh
mesh model/mesh
silo model/mesh
wrl model/vrml
vmrl model/vrml

asc text/plain
txt text/plain
rtx text/richtext
rtf text/rtf
sgml text/sgml
sgm text/sgml
tsv text/tab-separated-values
wml text/vnd.wap.wml
wmls text/vnd.wap.wmlscript
etx text/x-setext
xsl text/xml

mpeg video/mpeg
mpg video/mpeg
mpe video/mpeg
qt video/quicktime
mov video/quicktime
avi video/x-msvideo
movie video/x-sgi-movie

ice x-conference/x-cooltalk
3 changes: 3 additions & 0 deletions plugins/in_http/conf/sites/default.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[HOST]
ServerName @MK_VH_SERVERNAME@
DocumentRoot @MK_PATH_WWW@
17 changes: 11 additions & 6 deletions plugins/in_http/in_http.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,27 @@
* limitations under the License.
*/

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#include <msgpack.h>
#include <monkey/monkey.h>
#include <fluent-bit/flb_input.h>
#include <fluent-bit/flb_config.h>
#include <msgpack.h>

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#include "in_http.h"
#include "in_http_info.h"

/* Init CPU input */
int in_http_init(struct flb_config *config)
{
mk_config = mk_server_init();
mk_server_loop();
mk_config->server_conf_file = FLB_HTTP_CONFIG;
mk_config->path_config = FLB_HTTP_CONF_PATH;
mk_config->sites_conf_dir = FLB_HTTP_SITES;
mk_config->mimes_conf_file = FLB_HTTP_MIMES;
mk_server_setup();

return 0;
}
Expand Down
5 changes: 5 additions & 0 deletions plugins/in_http/in_http.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
#include <fluent-bit/flb_input.h>
#include <fluent-bit/flb_utils.h>

/* Default configuration for the HTTP server */
#define FLB_HTTP_CONFIG "in_http.conf"
#define FLB_HTTP_SITES "sites/"
#define FLB_HTTP_MIMES "mimetypes.conf"

struct flb_in_http_config {

/* MessagePack buffers */
Expand Down
25 changes: 25 additions & 0 deletions plugins/in_http/in_http_info.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

/* Fluent Bit
* ==========
* Copyright (C) 2015 Treasure Data Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#ifndef FLB_IN_HTTP_INFO_H
#define FLB_IN_HTTP_INFO_H

#define FLB_HTTP_CONF_PATH "@IN_HTTP_CONF_PATH@"

#endif

0 comments on commit 613720f

Please sign in to comment.