* [ANN] yahns 1.16.0 -_- sleepy app server for Ruby
@ 2018-08-06 1:32 6% Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2018-08-06 1:32 UTC (permalink / raw)
To: ruby-talk, yahns-public
A Free Software, multi-threaded, non-blocking network
application server designed for low _idle_ power consumption.
It is primarily optimized for applications with occasional users
which see little or no traffic. yahns currently hosts Rack/HTTP
applications, but may eventually support other application
types. Unlike some existing servers, yahns is extremely
sensitive to fatal bugs in the applications it hosts.
* git clone https://yhbt.net/yahns.git
* https://yhbt.net/yahns/README
* https://yhbt.net/yahns/NEWS.atom.xml (supported by most "RSS" readers)
* we only accept plain-text email yahns-public@yhbt.net
* and archive all the mail we receive: https://yhbt.net/yahns-public/
* nntp://news.public-inbox.org/inbox.comp.lang.ruby.yahns
lrg nabgure ubeevoyl-anzrq freire :>
Changes:
yahns 1.16.0
This release fixes warnings for users combining Rack::Deflater
with HTTPS support:
https://yhbt.net/yahns-public/20180714005630.11812-1-e@80x24.org/
yahns-rackup(1) users may not specify "-O listen=inherit"
when spawning from systemd. The "listen" directive may
be omitted entirely from the yahns-config(5) files.
A few other cleanups and nothing interesting, otherwise.
20 yawn-worthy changes since v1.15.0 (2017-03-23):
config: more descriptive variable name
proxy_pass: comment explaining what rack.hijack calls
USR2 upgrades may use Process.spawn for vfork
avoid Thread#[] and Thread#[]= across threads
gemspec: declare Ruby 2.0+ dependency, here
test_bin: SO_KEEPALIVE value only needs to be true
rackup_handler: remove unnecessary branch
test_bin: use RbConfig.ruby for non-standard names
allow omitting specifying socket name when inheriting listen socket
server: fix incomplete comment about SSLContext#setup
test_rack_env: additional test for Rack environment
test: allow setting TAIL env to watch error logs
fix some unused variables
tests: thread-safety fixes
test/server_helper: describe reason for termination
test/test_ssl: set SSLContext#security_level=0
doc: https:// URLs instead of git://
http_client: clear backtrace on "wrong version number" in OpenSSL
openssl_client: do not attempt writes after SystemCallError
use IO#pread if available in Ruby 2.5
*ZZZZZZ*
Please note the disclaimer:
yahns is extremely sensitive to fatal bugs in the apps it hosts. There
is no (and never will be) any built-in "watchdog"-type feature to kill
stuck processes/threads. Each yahns process may be handling thousands
of clients; unexpectedly killing the process will abort _all_ of those
connections. Lives may be lost!
yahns hackers are not responsible for your application/library bugs.
Use an application server which is tolerant of buggy applications
if you cannot be bothered to fix all your fatal bugs.
^ permalink raw reply [relevance 6%]
* [PATCH] allow omitting specifying socket name when inheriting listen socket
@ 2017-04-06 5:15 7% Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2017-04-06 5:15 UTC (permalink / raw)
To: yahns-public
Since the common case is still to run a single app inside yahns,
we can simplify setup a bit for systemd (and like) users by
allowing them to omit the "listen" directive when they are
running a single app in yahns.
---
Documentation/yahns-rackup.pod | 4 ++++
lib/yahns/config.rb | 5 +++++
lib/yahns/rackup_handler.rb | 6 +++---
lib/yahns/server.rb | 4 +++-
test/test_bin.rb | 47 +++++++++++++++++++++---------------------
5 files changed, 39 insertions(+), 27 deletions(-)
diff --git a/Documentation/yahns-rackup.pod b/Documentation/yahns-rackup.pod
index 3fbde0e..de2d4b6 100644
--- a/Documentation/yahns-rackup.pod
+++ b/Documentation/yahns-rackup.pod
@@ -40,6 +40,10 @@ and PATH is meant to be a path to a UNIX domain socket.
Defaults to "0.0.0.0:9292" (all addresses on TCP port 9292).
Multiple addresses may be separated with commas.
+For systemd users, a special value of "inherit" may be specified
+to inherit FDs using the LISTEN_FDS and LISTEN_PID environment
+variables described in L<sd_listen_fds(3)>
+
=item -O stderr_path=PATHNAME
Allow redirecting $stderr to a given path. Unlike doing this from
diff --git a/lib/yahns/config.rb b/lib/yahns/config.rb
index e545d59..bcea0d4 100644
--- a/lib/yahns/config.rb
+++ b/lib/yahns/config.rb
@@ -438,4 +438,9 @@ def commit!(server)
@app_ctx.each { |app| app.logger ||= server.logger }
end
+
+ def register_inherited(name)
+ return unless @config_listeners.empty? && @app_ctx.size == 1
+ @config_listeners[name] = { :yahns_app_ctx => @app_ctx[0] }
+ end
end
diff --git a/lib/yahns/rackup_handler.rb b/lib/yahns/rackup_handler.rb
index 63ab373..3f217af 100644
--- a/lib/yahns/rackup_handler.rb
+++ b/lib/yahns/rackup_handler.rb
@@ -16,10 +16,10 @@ def self.run(app, o)
# fine for most apps, but we have SIGUSR2 restarts to support
working_directory(Yahns::START[:cwd])
- app(:rack, app) do
+ app(:rack, app) do # Yahns::Config#app
addr = o[:listen] || "#{o[:Host]||default_host}:#{o[:Port]||8080}"
- # allow listening to multiple addresses
- addr.split(',').each { |l| listen(l) }
+ # allow listening to multiple addresses (Yahns::Config#listen)
+ addr.split(',').each { |l| listen(l) } unless addr == 'inherit'
val = o[:client_timeout] and client_timeout(val)
end
diff --git a/lib/yahns/server.rb b/lib/yahns/server.rb
index 43caae6..efd6f05 100644
--- a/lib/yahns/server.rb
+++ b/lib/yahns/server.rb
@@ -327,7 +327,9 @@ def inherit_listeners!
opts = sock_opts(io)
io = server_cast(io, opts)
set_server_sockopt(io, opts)
- @logger.info "inherited addr=#{sock_name(io)} fd=#{io.fileno}"
+ name = sock_name(io)
+ @logger.info "inherited addr=#{name} fd=#{io.fileno}"
+ @config.register_inherited(name)
io
end
diff --git a/test/test_bin.rb b/test/test_bin.rb
index 579e39c..e59c9b4 100644
--- a/test/test_bin.rb
+++ b/test/test_bin.rb
@@ -14,35 +14,36 @@ def setup
def test_listen_fd3
return unless RUBY_VERSION.to_f > 2.3 # Fixed in ruby/trunk r51209, actually
- @srv.setsockopt(:SOL_SOCKET, :SO_KEEPALIVE, 0)
host, port = @srv.addr[3], @srv.addr[1]
ru = tmpfile(%w(test_bin_daemon .ru))
ru.write("require 'rack/lobster'; run Rack::Lobster.new\n")
- cmd = %W(#{RbConfig.ruby} -I lib bin/yahns-rackup
- -E none -p #{port} -o #{host} #{ru.path})
- pid = fork do # emulate a systemd environment
- env = {
- 'LISTEN_PID' => $$.to_s,
- 'LISTEN_FDS' => '1',
- }
- exec env, *cmd, 3 => @srv, err: @err.path
- end
- Net::HTTP.start(host, port) do |http|
- req = Net::HTTP::Get.new("/")
- res = http.request(req)
- assert_equal 200, res.code.to_i
- assert_equal "keep-alive", res["Connection"]
+ cmd = %W(#{RbConfig.ruby} -I lib bin/yahns-rackup -E none #{ru.path})
+ [ %w(-O listen=inherit), %W(-p #{port} -o #{host}) ].each do |opt|
+ @srv.setsockopt(:SOL_SOCKET, :SO_KEEPALIVE, 0)
+ begin
+ pid = fork do # emulate a systemd environment
+ env = { 'LISTEN_PID' => $$.to_s, 'LISTEN_FDS' => '1' }
+ cmd.concat(opt)
+ exec env, *cmd, 3 => @srv, err: @err.path
+ end
+ Net::HTTP.start(host, port) do |http|
+ req = Net::HTTP::Get.new("/")
+ res = http.request(req)
+ assert_equal 200, res.code.to_i
+ assert_equal "keep-alive", res["Connection"]
+ end
+ assert @srv.getsockopt(:SOL_SOCKET, :SO_KEEPALIVE).bool,
+ 'ensure the inheriting process applies TCP socket options'
+ ensure
+ if pid
+ Process.kill(:QUIT, pid)
+ _, status = Process.waitpid2(pid)
+ assert status.success?, status.inspect
+ end
+ end
end
-
- assert @srv.getsockopt(:SOL_SOCKET, :SO_KEEPALIVE).bool,
- 'ensure the inheriting process applies TCP socket options'
ensure
- if pid
- Process.kill(:QUIT, pid)
- _, status = Process.waitpid2(pid)
- assert status.success?, status.inspect
- end
ru.close! if ru
end
--
EW
^ permalink raw reply related [relevance 7%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2017-04-06 5:15 7% [PATCH] allow omitting specifying socket name when inheriting listen socket Eric Wong
2018-08-06 1:32 6% [ANN] yahns 1.16.0 -_- sleepy app server for Ruby Eric Wong
Code repositories for project(s) associated with this public inbox
https://yhbt.net/yahns.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).