From: "Bráulio Bhavamitra" <braulio@eita.org.br>
To: Eric Wong <e@80x24.org>
Cc: unicorn-public <unicorn-public@bogomips.org>
Subject: Re: Master hooks needed
Date: Fri, 3 Oct 2014 23:04:05 -0300 [thread overview]
Message-ID: <CAJri6_sghhsfNttnN7MXQj_Jn1-XnfGt2qff3fgYbizTcJAcFA@mail.gmail.com> (raw)
In-Reply-To: <20141004015707.GA1951@dcvr.yhbt.net>
Documentation is an excelent solution :)
On Fri, Oct 3, 2014 at 10:57 PM, Eric Wong <e@80x24.org> wrote:
> Bráulio Bhavamitra <braulio@eita.org.br> wrote:
>> I think the hook is needed because I took too much time to figure out
>> the problem and much more time to figure out the solution (this
>> master_run variable). Also, I don't think this master_run solution is
>> elegant.
>
> A guard variable is fairly common practice for initialization.
> It's not always nice, but I do not consider the existing hooks
> to be elegant, either; they're only unfortunately necessary.
>
> I consider having redundant features to be even worse.
>
> How about the following documentation change instead?
>
> --- a/examples/unicorn.conf.rb
> +++ b/examples/unicorn.conf.rb
> @@ -54,12 +54,23 @@ GC.respond_to?(:copy_on_write_friendly=) and
> # fast LAN.
> check_client_connection false
>
> +# local variable to guard against running a hook multiple times
> +run_once = true
> +
> before_fork do |server, worker|
> # the following is highly recomended for Rails + "preload_app true"
> # as there's no need for the master process to hold a connection
> defined?(ActiveRecord::Base) and
> ActiveRecord::Base.connection.disconnect!
>
> + # Occasionally, it may be necessary to run non-idempotent code in the
> + # master before forking. Keep in mind the above disconnect! example
> + # is idempotent and does not need a guard.
> + if run_once
> + # do_something_once_here ...
> + run_once = false # prevent from firing again
> + end
> +
> # The following is only recommended for memory/DB-constrained
> # installations. It is not needed if your system can house
> # twice as many worker_processes as you have configured.
--
"Lute pela sua ideologia. Seja um com sua ideologia. Viva pela sua
ideologia. Morra por sua ideologia" P.R. Sarkar
EITA - Educação, Informação e Tecnologias para Autogestão
http://cirandas.net/brauliobo
http://eita.org.br
"Paramapurusha é meu pai e Parama Prakriti é minha mãe. O universo é
meu lar e todos nós somos cidadãos deste cosmo. Este universo é a
imaginação da Mente Macrocósmica, e todas as entidades estão sendo
criadas, preservadas e destruídas nas fases de extroversão e
introversão do fluxo imaginativo cósmico. No âmbito pessoal, quando
uma pessoa imagina algo em sua mente, naquele momento, essa pessoa é a
única proprietária daquilo que ela imagina, e ninguém mais. Quando um
ser humano criado mentalmente caminha por um milharal também
imaginado, a pessoa imaginada não é a propriedade desse milharal, pois
ele pertence ao indivíduo que o está imaginando. Este universo foi
criado na imaginação de Brahma, a Entidade Suprema, por isso a
propriedade deste universo é de Brahma, e não dos microcosmos que
também foram criados pela imaginação de Brahma. Nenhuma propriedade
deste mundo, mutável ou imutável, pertence a um indivíduo em
particular; tudo é o patrimônio comum de todos."
Restante do texto em
http://cirandas.net/brauliobo/blog/a-problematica-de-hoje-em-dia
next prev parent reply other threads:[~2014-10-04 2:04 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-03 11:34 Master hooks needed Bráulio Bhavamitra
2014-10-03 12:22 ` Eric Wong
2014-10-03 12:36 ` Valentin Mihov
2014-10-03 17:50 ` Eric Wong
2014-10-03 18:12 ` Valentin Mihov
2014-10-04 0:53 ` Bráulio Bhavamitra
2014-10-04 1:22 ` Eric Wong
2014-10-04 1:35 ` Bráulio Bhavamitra
2014-10-04 1:57 ` Eric Wong
2014-10-04 2:04 ` Bráulio Bhavamitra [this message]
2014-10-04 2:25 ` 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=CAJri6_sghhsfNttnN7MXQj_Jn1-XnfGt2qff3fgYbizTcJAcFA@mail.gmail.com \
--to=braulio@eita.org.br \
--cc=e@80x24.org \
--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).