From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-2.8 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, URIBL_BLOCKED shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: unicorn-public@bogomips.org Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 4A49D633819; Sat, 27 Jun 2015 03:05:01 +0000 (UTC) Date: Sat, 27 Jun 2015 03:05:01 +0000 From: Eric Wong To: Christos Trochalakis Cc: Dmitry Smirnov , Hleb Valoshka <375gnu@gmail.com>, unicorn@packages.debian.org, unicorn-public@bogomips.org Subject: Re: [DRE-maint] unicorn: native systemd service Message-ID: <20150627030501.GA24759@dcvr.yhbt.net> References: <3137844.nsIDTWmvl4@debstor> <20150625083118.GA22140@luke.ws.skroutz.gr> <20150625232626.GA23882@dcvr.yhbt.net> <20150626114129.GA25883@luke.ws.skroutz.gr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150626114129.GA25883@luke.ws.skroutz.gr> List-Id: Christos Trochalakis wrote: > On Thu, Jun 25, 2015 at 11:26:26PM +0000, Eric Wong wrote: > >With socket activation, you should just be able to kill unicorn using > >SIGQUIT (just master, or even all workers) and restart without ever > >dropping a connection. I do NOT suggest using SIGTERM for unicorn, > >since that'll cause the master to kill all workers ASAP. > > Yes, you are right socket activation is also an option! I have made some > experiments with a simple rack app to test it. > > systemd uses the LISTEN_FDS env variable that is an integer indicating the > number of inherited file descriptors. Those FDs have consecutive numbers > starting from `SD_LISTEN_FDS_START` which is `3` (man sd_listen_fds). > > So for example if LISTEN_FDS="2", UNICORN_FD should be "3,4". I used a > simple wrapper script for that. Here is the full configuration: OK, I'll probably add LISTEN_FDS and LISTEN_PID support to unicorn directly so the wrapper is unnecessary. > KillMode=mixed I don't think KillMode=mixed is necessary, here. systemd can send SIGQUIT to workers. > TCP socket options are not applied by unicorn on inherited sockets (TCPSocket > === sock is false). systemd socket files have support for most options now but > we might want unicorn to `setsockopt` them as well. For example, > 'DeferAcceptSec', 'KeepAliveIntervalSec', 'NoDelay' are supported since v216, so > they are not available in jessie (v215). They are now :) http://bogomips.org/unicorn-public/m/1435373879-4299-1-git-send-email-e@80x24.org.txt We don't have KeepAliveIntervalSec (aka TCP_KEEPINTVL) since it's not-portable and probably over Are you sure about that? > socket activation is a really interesting setup, but personally I would not run > it with a large application. Clients would have to wait for the new master to > be up and running before a reply is returned, and that could take tenths of > seconds. The USR2 rexec solves that problem since both old and new workers are > accepting on the socket and we can kill the old ones when we are ready. In that > case the PIDFile trick is handy to support zero downtime restarts with no > latency. Is it possible to make systemd fire up two unicorn masters? That would be a nice feature to have with socket activation.