diff options
Diffstat (limited to 'lib/yahns.rb')
-rw-r--r-- | lib/yahns.rb | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/lib/yahns.rb b/lib/yahns.rb new file mode 100644 index 0000000..373fca0 --- /dev/null +++ b/lib/yahns.rb @@ -0,0 +1,66 @@ +# Copyright (C) 2013, Eric Wong <normalperson@yhbt.net> and all contributors +# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) +require 'unicorn' # pulls in raindrops, kgio, fcntl, etc, stringio, and logger +require 'sleepy_penguin' + +# yahns exposes no user-visible API outside of the config file +# Internals are subject to change. +module Yahns # :nodoc: + # We populate this at startup so we can figure out how to reexecute + # and upgrade the currently running instance of yahns + # Unlike unicorn, this Hash is NOT a stable/public interface. + # + # * 0 - the path to the yahns executable + # * :argv - a deep copy of the ARGV array the executable originally saw + # * :cwd - the working directory of the application, this is where + # you originally started yahns. + # + # To change your yahns executable to a different path without downtime, + # you can set the following in your yahns config file, HUP and then + # continue with the traditional USR2 + QUIT upgrade steps: + # + # Yahns::START[0] = "/home/bofh/2.0.0/bin/yahns" + START = { + :argv => ARGV.map { |arg| arg.dup }, + 0 => $0.dup, + } + + # We favor ENV['PWD'] since it is (usually) symlink aware for Capistrano + # and like systems + START[:cwd] = begin + a = File.stat(pwd = ENV['PWD']) + b = File.stat(Dir.pwd) + a.ino == b.ino && a.dev == b.dev ? pwd : Dir.pwd + rescue + Dir.pwd + end + + # Raised inside TeeInput when a client closes the socket inside the + # application dispatch. This is always raised with an empty backtrace + # since there is nothing in the application stack that is responsible + # for client shutdowns/disconnects. + class ClientShutdown < EOFError # :nodoc: + end +end + +# FIXME: require lazily +require_relative 'yahns/log' +require_relative 'yahns/queue_epoll' +require_relative 'yahns/stream_input' +require_relative 'yahns/tee_input' +require_relative 'yahns/queue_egg' +require_relative 'yahns/client_expire' +require_relative 'yahns/http_response' +require_relative 'yahns/http_client' +require_relative 'yahns/http_context' +require_relative 'yahns/queue' +require_relative 'yahns/config' +require_relative 'yahns/tmpio' +require_relative 'yahns/worker' +require_relative 'yahns/sigevent' +require_relative 'yahns/daemon' +require_relative 'yahns/socket_helper' +require_relative 'yahns/server' +require_relative 'yahns/fdmap' +require_relative 'yahns/acceptor' +require_relative 'yahns/wbuf' |