Skip to content

Instantly share code, notes, and snippets.

@yannick
Created March 21, 2017 21:08
Show Gist options
  • Save yannick/df6a6015c21776590f5698ac60a79e4b to your computer and use it in GitHub Desktop.
Save yannick/df6a6015c21776590f5698ac60a79e4b to your computer and use it in GitHub Desktop.
listen:
port: 8080
hosts:
"*":
paths:
/nstatuz:
status: ON
/:
mruby.handler: |
redis = H2O::Redis.new(:host => '127.0.0.1', :port => 6379)
Proc.new do |env|
set = redis.set('::1', '8045')
get = redis.get(env['REMOTE_ADDR'])
# redis.disconnect
[ 200, { "Content-Type" => "application/json" }, [ '{"zip": "', get.join, '"}\n'] ]
end
access-log:
path: /dev/stdout
format: "%{ssl.session-reused}x\t%{connection-id}x\t%{ssl.cipher}x\t%{ssl.session_ticket}x%{ssl.session-ticket}x"
[Unit]
Description=H2O - the optimized HTTP/1, HTTP/2 server
After=network-online.target nss-lookup.target remote-fs.target
[Service]
Type=simple
PIDFile=/run/h2o.pid
ExecStart=/usr/bin/h2o --mode master --conf /etc/h2o.conf
ExecReload=/usr/bin/kill -HUP $MAINPID
ExecStop=/usr/bin/kill -TERM $MAINPID
SyslogLevel=notice
PrivateTmp=true
LimitNOFILE=infinity
[Install]
WantedBy=multi-user.target
MRuby::Build.new do |conf|
# load specific toolchain settings
# Gets set by the VS command prompts.
if ENV['MRUBY_TOOLCHAIN']
toolchain ENV['MRUBY_TOOLCHAIN']
elsif ENV['VisualStudioVersion'] || ENV['VSINSTALLDIR']
toolchain :visualcpp
else
toolchain :gcc
end
# enable_debug
# use mrbgems
Dir.glob("../mruby-*/mrbgem.rake") do |x|
g = File.basename File.dirname x
if g == 'mruby-onig-regexp'
conf.gem "../deps/#{g}" do |c|
c.bundle_onigmo
end
else
conf.gem "../deps/#{g}"
end
end
# conf.gem :github => 'matsumoto-r/mruby-vedis'
# conf.gem :git => 'https://github.com/matsumoto-r/mruby-redis.git'
conf.gem :github => 'mattn/mruby-json'
# conf.gem :github => 'take-cheeze/mruby-leveldb'
conf.gem :github => 'mattn/mruby-sqlite3'
conf.gem :github => 'matsumoto-r/mruby-http2'
conf.gem :github => 'udzura/mruby-etcd'
# conf.gem :github => 'mattn/mruby-sqlite3'
# conf.gem :github => 'iij/mruby-aws-s3'
# conf.gem :github => 'mattn/mruby-uv'
# conf.gem :github => 'mattn/mruby-http'
# conf.gem :github => 'matsumoto-r/mruby-httprequest'
# conf.gem :github => 'iij/mruby-digest'
# conf.gem :github => 'iij/mruby-pack'
conf.gem :github => 'Asmod4n/mruby-simplemsgpack'
# conf.gem :github => 'matsumoto-r/mruby-simplehttp'
# conf.gem :github => 'iij/mruby-socket'
# conf.gem :git => 'https://github.com/luisbebop/mruby-polarssl.git'
# include all the core GEMs
conf.gembox 'full-core'
end
# Maintainer: Yannick Koechlin <yannick.koechlin@tamedia.ch>
pkgname=h2o-future
pkgver=r3959.4bc17f98
pkgrel=1
pkgdesc="Optimized HTTP server with support for HTTP/1.x and HTTP/2. git version with extra gems"
arch=('i686' 'x86_64')
depends=('libuv' 'libyaml' 'wslay' 'zlib' 'sqlite3' 'leveldb' 'hiredis' 'librdkafka-git' 'nghttp2' 'curl' 'mbedtls')
makedepends=('cmake' 'libtool' 'make' 'pkg-config' 'ruby')
url="https://github.com/h2o/h2o"
license=('MIT')
source=("$pkgname"::'git+https://github.com/tamediadigital/h2o.git#branch=distribution'
h2o.service
mruby_config.rb
)
sha256sums=('SKIP'
'8a85462b6798deaaab343b5dae73437e251c5018d70d260a4a4440b9bbb053e6'
'SKIP'
)
backup=('etc/h2o.conf')
provides=('h2o' 'libh2o')
conflicts=('libh2o' 'h2o')
pkgver() {
cd "$srcdir/${pkgname}"
printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
}
build() {
cd "$srcdir/$pkgname"
# cp ../../mruby_config.rb misc/mruby_config.rb
# rm -rf deps/mruby
# git clone https://github.com/mruby/mruby deps/mruby
git submodule update --init --recursive
msg2 'Building...'
cmake \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCMAKE_INSTALL_LIBDIR='/usr/lib' \
-DCMAKE_SKIP_RPATH='TRUE' \
-DWITH_BUNDLED_SSL=ON \
-DWITH_RDKAFKA=on \
-DEXTRA_LIBS="" \
-DWITH_MRUBY=on \
.
make
make libh2o
}
package() {
cd "$srcdir/$pkgname"
msg2 'Installing license...'
install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
msg2 'Installing documentation...'
install -Dm 644 README.md "$pkgdir/usr/share/doc/$pkgname/README.md"
msg2 'Installing systemd service...'
install -Dm 644 "$srcdir/h2o.service" "$pkgdir/usr/lib/systemd/system/h2o.service"
msg2 'Installing conf file...'
install -Dm 644 examples/h2o/h2o.conf "$pkgdir/etc/h2o.conf"
msg2 'Installing...'
make DESTDIR="$pkgdir" install
}
@taosx
Copy link

taosx commented Apr 13, 2017

Thank YOU!! 👍
I've been trying for the last 4 hours to add mruby gems. I found h2o/h2o#993 but it doesn't work by dumping gems inside deps even with 'mruby-name' , by modifying misc/mruby_config.rb works like a charm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment