unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Eric Wong <e@80x24.org>
To: Peter Giacomo Lombardo <peter.lombardo@instana.com>
Cc: unicorn-public@bogomips.org
Subject: Re: Storing Multiple Blocks for Configurator Hooks
Date: Mon, 28 Nov 2016 17:57:35 +0000	[thread overview]
Message-ID: <20161128175735.GA25338@starla> (raw)
In-Reply-To: <5B3FDDDF-5910-4672-84CA-ED07A7CEC8C6@instana.com>

Peter Giacomo Lombardo <peter.lombardo@instana.com> wrote:
> Please excuse if this has been discussed or already decided upon - searches came up with nothing.

Nope, I don't recall this coming up on the list.

> Has unicorn considered allowing multiple blocks to be supplied for Configurator Hooks (e.g. after_fork et. al.)?

Yes, but only briefly in the earliest stages of the project.  I
rejected it since it make things more difficult to debug and
track down.

Nowadays, it could break an existing use case:

	after_fork do
	  # ... many lines
	end
	after_fork {} # nothing, temporarily disable initial block

	(I realize putting " if false" after "end" can also disable
	 the block, but I suspect many folks who configure unicorn
	 are not regularly Rubyists).

> Currently, it seems that only one block can be specified:
> https://bogomips.org/unicorn.git/tree/lib/unicorn/configurator.rb#n628
> 
> If instead this were stored as an array of blocks, gems could register their own blocks to be run when the hooks are called which would result in less end-user burden and easier on-ramping to get a running system.  

It seems like it would be a management problem if the config got
too big and were split into many pieces.  It would be extra bad
if it were difficult to know ordering (FIFO? LIFO?) and which
part of the config each part is in.

You can manage an array yourself:

	af_cb = []
	after_fork { af_cb.each(&:call) }
	af_cb << lambda { ... }
	af_cb << lambda { ... }

> (Confronting the ActiveRecord establish_connection and Redis re-connect seem to be a rite of passage into using Unicorn)

preload_app has always defaulted to "false" for this reason :)

Also, isn't a mere disconnect all that's necessary nowadays, as
connections are made on demand?  At least that's how Sequel
behaves.  I haven't touched AR/Rails in years (since a JS
engine became mandatory).

  reply	other threads:[~2016-11-28 17:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-28 16:26 Storing Multiple Blocks for Configurator Hooks Peter Giacomo Lombardo
2016-11-28 17:57 ` Eric Wong [this message]
2016-11-29 21:29   ` Peter Giacomo Lombardo
2016-11-30  4:26     ` Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://yhbt.net/unicorn/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161128175735.GA25338@starla \
    --to=e@80x24.org \
    --cc=peter.lombardo@instana.com \
    --cc=unicorn-public@bogomips.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhbt.net/unicorn.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).