From normalperson at yhbt.net Wed Feb 1 13:14:45 2012 From: normalperson at yhbt.net (Eric Wong) Date: Wed, 1 Feb 2012 18:14:45 +0000 Subject: FreeBSD jail and unicorn In-Reply-To: References: <20120131190502.GA8578@dcvr.yhbt.net> Message-ID: <20120201181445.GA31624@dcvr.yhbt.net> Philipp Bruell wrote: > First of all, thank you for your fast reply. No problem, depends on the time of day of course :> > The behaviour details Charles described are correct and we are using ruby > version 1.9.3. > > It's good that you've asked for the other signals. I've checked them in > particular and it seems that it is a common signal handling problem. The > process freaks out on each of them :-( > > I've attached the output of truss -f for a QUIT signal. That signal took a > quite long time to get processed (and took all CPU cycles), but finally > worked. I only saw the output from the master process there, nothing from the worker. It seems like the master is OK, but trying to kill the worker is not. I wonder if it's related to https://bugs.ruby-lang.org/issues/5240 With the following script, can you try sending SIGQUIT to the parent and see what happens? ------------------------------- 8< ----------------------------- pid = fork do r, w = IO.pipe trap(:QUIT) do puts "SIGQUIT received in child, exiting" w.close end r.read end trap(:QUIT) do puts "SIGQUIT received in parent, killing child" Process.kill(:QUIT, pid) p Process.waitpid2(pid) exit end sleep 1 # wait for child to setup sig handler puts "Child ready on #{pid}, parent on #$$" sleep ---------------------------------------------------------------- If the above fails, try with different variables: * without a jail on the same FreeBSD version/release/patchlevel * Ruby 1.9.2 (which has a different signal handling implementation) * different FreeBSD version * different architecture[1] Mixing either signal handling or fork()-ing in the presence of threads is tricky. Ruby 1.9 uses a dedicated thread internally for signal handling, I wouldn't be surprised if there's a bug lingering somewhere in FreeBSD or Ruby... Have you checked the FreeBSD mailing lists/bug trackers? I don't recall seeing anything other than the aforementioned bug in ruby-core... [1] - I expect there's ASM involved in signal/threading implementation details, so there's a chance it's x86_64-specific... > The output of USR2 signal is too long to attach it to a mail, but at a > first sight, it repeats the following calls over and over again. Don't send monster attachments, host it somewhere else so mail servers won't reject it for wasting bandwidth. The mailman limit on rubyforge is apparently 256K (already huge IMHO). Also, don't top post > 24864: > thr_kill(0x18c32,0x1a,0x800a8edc0,0x18a86,0x7fffffbeaf80,0x80480c000) = 0 > (0x0) > 24864: select(4,{3},0x0,0x0,{0.100000 }) = 1 (0x1) > 24864: read(3,"!",1024) = 1 (0x1) OK, so the signal is received correctly by the Ruby VM in the master. I just don't see anything in the worker, but the master does attempt to forward SIGQUIT to the worker. > It also seems to me, that observing the processes with truss changes the > behaviour a lot. During the observed USR2 the master process spawns a lot > (about 30) of processes. I never had this before. Some processes react strangely to being traced. Maybe there's something better than truss nowadays? From normalperson at yhbt.net Thu Feb 2 14:31:36 2012 From: normalperson at yhbt.net (Eric Wong) Date: Thu, 2 Feb 2012 19:31:36 +0000 Subject: FreeBSD jail and unicorn In-Reply-To: References: <20120201181445.GA31624@dcvr.yhbt.net> Message-ID: <20120202193136.GA1478@dcvr.yhbt.net> Philipp Bruell wrote: > On 01/02/2012 19:14, "Eric Wong" wrote: > >Philipp Bruell wrote: > The scripts behaves exactly like unicorn. The master received the QUIT and > passes it to the child. The child also receives it, but don't exit. While > the master is waiting for the child to exit, it consumes all the cpu > cycles. Interesting, I suspect it's some bad interaction with fork() causing signal handlers/pthreads to go bad. I expect the following simple script to work flawlessly since it doesn't fork: ---------------------------------------- trap(:QUIT) { exit(0) } puts "Ready for SIGQUIT on #$$" sleep ---------------------------------------- > I don't have the option, to test without jail, on a different FreeBSD > version nor a different architecture (and FreeBSD - on Mac OS X everything > works perfect). But I tried ruby version 1.9.2 and that works! So I guess > it's a bug with 1.9.3 on FreeBSD. Can you report this as a bug to the Ruby core folks on https://bugs.ruby-lang.org/ and also to whereever the FreeBSD hackers take bug reports? Somebody from one of those camps should be able to resolve the issue. The good thing is my small sample script is enough to reproduce the issue, so it should be easy for an experienced FreeBSD hacker to track down. > I've attached the truss -f output of the child process of the test script. > But the observation with truss made the problem disappear again :-( It could be a timing or race condition issue. I've had strace on linux find/hide bugs because it slowed the program down enough. From normalperson at yhbt.net Thu Feb 2 17:27:15 2012 From: normalperson at yhbt.net (Eric Wong) Date: Thu, 2 Feb 2012 22:27:15 +0000 Subject: FreeBSD jail and unicorn In-Reply-To: <20120202193136.GA1478@dcvr.yhbt.net> References: <20120201181445.GA31624@dcvr.yhbt.net> <20120202193136.GA1478@dcvr.yhbt.net> Message-ID: <20120202222715.GA22683@dcvr.yhbt.net> Eric Wong wrote: > Can you report this as a bug to the Ruby core folks on > https://bugs.ruby-lang.org/ and also to whereever the FreeBSD hackers > take bug reports? Somebody from one of those camps should be able > to resolve the issue. A total stab in the dark, but I posted this patch to ruby-core anyways to find more testers/reviewers: http://mid.gmane.org/20120202221946.GA32004 at dcvr.yhbt.net Mind giving it a shot? From normalperson at yhbt.net Thu Feb 2 17:41:34 2012 From: normalperson at yhbt.net (Eric Wong) Date: Thu, 2 Feb 2012 22:41:34 +0000 Subject: FreeBSD jail and unicorn In-Reply-To: <20120202222715.GA22683@dcvr.yhbt.net> References: <20120201181445.GA31624@dcvr.yhbt.net> <20120202193136.GA1478@dcvr.yhbt.net> <20120202222715.GA22683@dcvr.yhbt.net> Message-ID: <20120202224134.GB9233@dcvr.yhbt.net> Eric Wong wrote: > A total stab in the dark, but I posted this patch to ruby-core anyways > to find more testers/reviewers: > > http://mid.gmane.org/20120202221946.GA32004 at dcvr.yhbt.net Oops, and I just posted a follow-up since the original was a no-op due to ordering issues :x http://mid.gmane.org/20120202223945.GA9233 at dcvr.yhbt.net From normalperson at yhbt.net Thu Feb 2 18:41:33 2012 From: normalperson at yhbt.net (Eric Wong) Date: Thu, 2 Feb 2012 23:41:33 +0000 Subject: FreeBSD jail and unicorn In-Reply-To: <20120202224134.GB9233@dcvr.yhbt.net> References: <20120201181445.GA31624@dcvr.yhbt.net> <20120202193136.GA1478@dcvr.yhbt.net> <20120202222715.GA22683@dcvr.yhbt.net> <20120202224134.GB9233@dcvr.yhbt.net> Message-ID: <20120202234133.GB32287@dcvr.yhbt.net> Eric Wong wrote: > > A total stab in the dark, but I posted this patch to ruby-core anyways > > to find more testers/reviewers: Last attempt at a patch on this issue, I'm just shotgunning here :x http://bogomips.org/ruby.git/patch/?id=418827f4e41a618d91 From normalperson at yhbt.net Thu Feb 2 21:58:04 2012 From: normalperson at yhbt.net (Eric Wong) Date: Fri, 3 Feb 2012 02:58:04 +0000 Subject: FreeBSD jail and unicorn In-Reply-To: <20120202234133.GB32287@dcvr.yhbt.net> References: <20120201181445.GA31624@dcvr.yhbt.net> <20120202193136.GA1478@dcvr.yhbt.net> <20120202222715.GA22683@dcvr.yhbt.net> <20120202224134.GB9233@dcvr.yhbt.net> <20120202234133.GB32287@dcvr.yhbt.net> Message-ID: <20120203025804.GA27035@dcvr.yhbt.net> ruby-core pointed me to the following issue: https://bugs.ruby-lang.org/issues/5757 So there may already be a fix in Ruby SVN, can you test? http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_3 r34425 From niekkaksas52gnasm at yahoo.com Fri Feb 3 03:15:43 2012 From: niekkaksas52gnasm at yahoo.com (Rick) Date: Fri, 3 Feb 2012 16:15:43 +0800 Subject: =?GB2312?B?RGlnaXRhbCBQaG90byBFZGl0aW5nIFNlcnZpY2VzIC0gUGhvdG8gQ3V0b3V0?= Message-ID: You are receiving this email because we wish you to use our digital photo editing services. We are a China based Imaging Professionals. We offer basic and advanced digital photo Editing services and solutions like photo Cutout, morphological photo Editing, photoshop photo Editing, satellite photo Editing, color photo Editing and vector photo Editing using latest techniques. Our mainly services are: 1. Photo Cutout 2. Photo Enhancement 3. Photo Retouching 4. Vector Conversion 5. Pop Art 6. Images Masking 7. Clipping Path 8. Photo Restoration 9. Web Design Looking forward to work for you! Best regards, Rick Toeagrimoit Imaging Professionals Contact: ibwallace at yeah.net Send address to imremove at yeah.net for remove From dnagir at gmail.com Sun Feb 5 08:17:44 2012 From: dnagir at gmail.com (Dmytrii Nagirniak) Date: Mon, 6 Feb 2012 00:17:44 +1100 Subject: Deployment with Capistrano and Foreman Message-ID: <7343F347-B9FB-404A-A6CF-21C20A0850C0@gmail.com> Hi guys, I wonder how do you deploy Unicorn Rails apps using Foreman and the upstart. The things I'm not sure how to deal with are: - restarting the Unicorn with no downtime. With upstart I think the master process gets restarted. - running app as unprivileged user (not sure how to use Forman with upstat at all here). A lot of things are really related to Foreman (the ruby one), but it would help to hear some of the ways you guys do it. Cheers, Dmytrii. http://ApproachE.com From normalperson at yhbt.net Sun Feb 5 16:45:16 2012 From: normalperson at yhbt.net (Eric Wong) Date: Sun, 5 Feb 2012 21:45:16 +0000 Subject: Deployment with Capistrano and Foreman In-Reply-To: <7343F347-B9FB-404A-A6CF-21C20A0850C0@gmail.com> References: <7343F347-B9FB-404A-A6CF-21C20A0850C0@gmail.com> Message-ID: <20120205214516.GA21881@dcvr.yhbt.net> Dmytrii Nagirniak wrote: > I wonder how do you deploy Unicorn Rails apps using Foreman and the upstart. > > The things I'm not sure how to deal with are: > > - restarting the Unicorn with no downtime. With upstart I think the master > process gets restarted. I'll defer to actual Foreman/upstart users for this. Any solution that works with nginx (while keeping the master process in use) should work with unicorn, too. I designed unicorn so it could be managed nearly identically to nginx. > - running app as unprivileged user (not sure how to use Forman with > upstat at all here). You can use the "user" directive in the unicorn config file, this only affects the worker processes, though. http://unicorn.bogomips.org/Unicorn/Configurator.html#method-i-user You can always use su or sudo to ensure the master process is unprivileged, too. From normalperson at yhbt.net Tue Feb 7 00:21:30 2012 From: normalperson at yhbt.net (Eric Wong) Date: Tue, 7 Feb 2012 05:21:30 +0000 Subject: FreeBSD jail and unicorn In-Reply-To: <20120203025804.GA27035@dcvr.yhbt.net> References: <20120201181445.GA31624@dcvr.yhbt.net> <20120202193136.GA1478@dcvr.yhbt.net> <20120202222715.GA22683@dcvr.yhbt.net> <20120202224134.GB9233@dcvr.yhbt.net> <20120202234133.GB32287@dcvr.yhbt.net> <20120203025804.GA27035@dcvr.yhbt.net> Message-ID: <20120207052130.GA4730@dcvr.yhbt.net> Eric Wong wrote: > ruby-core pointed me to the following issue: > https://bugs.ruby-lang.org/issues/5757 > > So there may already be a fix in Ruby SVN, can you test? > http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_3 r34425 Btw, did anybody get a chance to try this? While working on an unrelated project, I setup FreeBSD 8.2 and 9.0 KVM images over the weekend. Since I had the KVM images handy, I also tried to reproduce this issue under 1.9.3-p0 (without a jail) but was unable to reproduce the issue under either 8.2 nor 9.0. I tried building a jail, but didn't have enough space for a full one. If I get the chance, I'll see how building a partial jail goes, but I'm not optimistic about being able to reproduce this issue under KVM since it seems to be a race condition/timing issue. I even had both CPU cores enabled under KVM and even installed the virtio drivers for better performance. I assume you guys are using SMP in the jail? From Philipp.Bruell at skrill.com Tue Feb 7 02:36:31 2012 From: Philipp.Bruell at skrill.com (Philipp Bruell) Date: Tue, 7 Feb 2012 07:36:31 +0000 Subject: FreeBSD jail and unicorn In-Reply-To: <20120207052130.GA4730@dcvr.yhbt.net> Message-ID: Hi, Sorry for my late rely. On 07/02/2012 07:21, "Eric Wong" wrote: >Eric Wong wrote: >> ruby-core pointed me to the following issue: >> https://bugs.ruby-lang.org/issues/5757 >> >> So there may already be a fix in Ruby SVN, can you test? >> http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_3 r34425 > >Btw, did anybody get a chance to try this? I haven't tried it yet. Currently, we are using RVM to install ruby, but as soon as I've some time, I'll setup a source version of ruby and apply some of these patches. > >While working on an unrelated project, I setup FreeBSD 8.2 and 9.0 >KVM images over the weekend. Since I had the KVM images handy, I also >tried to reproduce this issue under 1.9.3-p0 (without a jail) but was >unable to reproduce the issue under either 8.2 nor 9.0. Yeah - I've also ask a college to test it under FreeBSD (without Jail) and he can't reproduce it either. It seems to be a Jail problem (I would run in cycles too, if I would be in Jail ;-). >I tried building a jail, but didn't have enough space for a full one. >If I get the chance, I'll see how building a partial jail goes, but I'm >not optimistic about being able to reproduce this issue under KVM >since it seems to be a race condition/timing issue. > >I even had both CPU cores enabled under KVM and even installed the >virtio drivers for better performance. > >I assume you guys are using SMP in the jail? Yes - I'm pretty sure that SMP is involved. Kind regards Philipp From Charles.Hornberger at skrill.com Tue Feb 7 04:59:49 2012 From: Charles.Hornberger at skrill.com (Charles Hornberger) Date: Tue, 7 Feb 2012 09:59:49 +0000 Subject: FreeBSD jail and unicorn In-Reply-To: Message-ID: On 2/7/12 9:36 AM, Philipp.Bruell at skrill.com wrote: >Yes - I'm pretty sure that SMP is involved. The Jail is on a (big) SMP box, and we definitely have access to all the CPUs. And since the process consumes 200% of cpu according to ps, it seems clear that at least 2 CPUs are involved... From valdivia971 at yahoo.com.br Wed Feb 15 20:24:41 2012 From: valdivia971 at yahoo.com.br (Pedro Valdivia) Date: Wed, 15 Feb 2012 23:24:41 -0200 Subject: Uma Boa Dica para Você Message-ID: Ola Eu gostaria de lhe convidar para conhecer o Sistema Renda Online. Trata-se de um Sistema Inovador de ganhos na internet, onde voc? ? o patr?o! ? isso mesmo! Voc? vai trabalhar pra voc?, pois eu nunca imaginei que poderia ganhar dinheiro na internet desta formar e t?o r?pido. E melhor de tudo! investir apenas uma ?nica vez e posso ganhar infinitamente. Voc? ficar? chocado com nosso m?todo para Ganhar Dinheiro Online No Sistema Renda Online: Voc? ganha 100% de lucro, recebendo seu dinheiro direto na sua conta pagSeguro Voc? ganha 24 horas por dia at? mesmo enquanto dorme Voc? ganha um site personalizado com seu nome e sua conta Voc? ganha diversas apostilas digitais e cursos gr?tis Voc? ter? o melhor sistema de Renda Extra que j? viu aqui no Brasil Ent?o lhe convido a se tornar um empreendedor web como eu! Mas para se cadastrar, use este link: http://www.sistemarendaonline.com/id.php?ind=403 Dessejo-lhe Sucessos!, Pedro Valdivia pedro.borquez at hotmail.com From lucas at envato.com Thu Feb 16 21:29:01 2012 From: lucas at envato.com (Lucas Parry) Date: Fri, 17 Feb 2012 13:29:01 +1100 Subject: Bug in unicorn_rails when Encoding.default_internal is set Message-ID: Hi, We recently made the switch to 1.9 for our large rails 2.3.14 project and ran into some strange behavior from the unicorns where encoding problem would cause blank 500 pages to be "randomly" served to users (we run ~10 x 5 unicorn workers behind our load balancer). We found that unicorn workers were dying when someone requested a url with utf-8 in it, and died in such a way that subsequent requests to that worker would get the same blank 500 page even for plain ascii urls. I've been able to recreate this behavior one a fresh rails project by setting Encoding.default_internal to utf-8 and very little else. I've created an example repo at: https://github.com/lparry/how_to_kill_a_unicorn All you need to do is hit http://localhost:8080/users/? and the unicorn worker will die with an error: "Error during failsafe response: "\xE2" from ASCII-8BIT to UTF-8" "app error: "You have a nil object when you didn't expect it!\nYou might have expected an instance of Array.\nThe error occurred while evaluating nil.each" (NoMethodError)" All subsequent requests to that worker will fail with the same exception. Is this a known issue? Is there a recommended work around? Cheers, Lucas Parry Envato From lucas at envato.com Thu Feb 16 21:37:37 2012 From: lucas at envato.com (Lucas Parry) Date: Fri, 17 Feb 2012 13:37:37 +1100 Subject: Bug in unicorn_rails when Encoding.default_internal is set In-Reply-To: References: Message-ID: On Fri, Feb 17, 2012 at 1:29 PM, Lucas Parry wrote: > We recently made the switch to 1.9 for our large rails 2.3.14 project I guess I should be more precise; This problem is occurring on MRI1.9.2-p290 From normalperson at yhbt.net Thu Feb 16 22:59:20 2012 From: normalperson at yhbt.net (Eric Wong) Date: Fri, 17 Feb 2012 03:59:20 +0000 Subject: Bug in unicorn_rails when Encoding.default_internal is set In-Reply-To: References: Message-ID: <20120217035920.GA31001@dcvr.yhbt.net> Lucas Parry wrote: > On Fri, Feb 17, 2012 at 1:29 PM, Lucas Parry wrote: > > We recently made the switch to 1.9 for our large rails 2.3.14 project (odd, neither I nor gmane got your original message: http://rubyforge.org/pipermail/mongrel-unicorn/2012-February/001310.html Perhaps Mailman misdelivers UTF-8... ) > I guess I should be more precise; This problem is occurring on MRI1.9.2-p290 Setting Encoding.default_* is probably a bad idea in your app. If you run Ruby with warnings (-w switch), you'll see setting Encoding.default_* will generate warnings to discourage their use. If you want UTF-8, set LANG=en_US.UTF-8 in the environment _before_ starting Ruby, which will only set Encoding.default_external. I've always just left Encoding.default_internal alone. I'll let others on the list with more Rails/encoding experience help you with that. > All subsequent requests to that worker will fail with the same > exception. Seems to be Rails bug. Rails 3.2.1 seems to handle the situation without difficulty. Fwiw, neither Rack nor HTTP specify an encoding for HTTP headers/paths. The only place where encoding is specified for Rack is "rack.input", which must be binary. There was talk on the Rack mailing list a long while back about enforcing encodings for certain headers, but nothing came of it. From patrick at collinatorstudios.com Thu Feb 23 02:29:07 2012 From: patrick at collinatorstudios.com (Patrick J. Collins) Date: Wed, 22 Feb 2012 18:29:07 -0800 (PST) Subject: using unicorn as a local development server Message-ID: Hi Unicorn friends, I wanted to try out Unicorn as my development server and I see that I need to perform some configuration to make this work nicely with rails. >From what I can tell the only real things I need to do to make unicorn similar to the default rails server is to supply a config file with: listen 3000 logger Logger.new(STDOUT) ... After creating this file, I was kind of confused as to how to proceed.. Should I made a bash alias like alias unicorn="unicorn_rails -c /path/to/unicorn_config.rb" and lastly, is there a convention where a configuration file like this should go on a unix/OS X system? Thank you kindly. Patrick J. Collins http://collinatorstudios.com From normalperson at yhbt.net Thu Feb 23 04:30:07 2012 From: normalperson at yhbt.net (Eric Wong) Date: Thu, 23 Feb 2012 04:30:07 +0000 Subject: using unicorn as a local development server In-Reply-To: References: Message-ID: <20120223043007.GA20356@dcvr.yhbt.net> "Patrick J. Collins" wrote: > Hi Unicorn friends, > > I wanted to try out Unicorn as my development server and I see that I > need to perform some configuration to make this work nicely with rails. > >From what I can tell the only real things I need to do to make unicorn > similar to the default rails server is to supply a config file with: > > listen 3000 > logger Logger.new(STDOUT) Hi Patrick, You shouldn't even need the logger directive, it goes to stderr by default so your console will still show it. > After creating this file, I was kind of confused as to how to proceed.. > Should I made a bash alias like > > alias unicorn="unicorn_rails -c /path/to/unicorn_config.rb" I generally avoid shell aliases for per-app/project things since I split my work across different apps + terminals + machines. If I'm (rarely) developing an app that _requires_ a persistently running web server, I'd just run in the foreground and Ctrl-C/ to use my shell history. Normally I just write integration tests (sometimes starting unicorn (or zbatery) + hitting it with curl, but often just mocking a Rack env). Unlike most folks that develop apps that run over HTTP, I have a strong aversion to web browsers. I'd rather pipe curl output to "vim -" if I have to look at any text output from the application. You'll probably get different answers from other folks here :) > and lastly, is there a convention where a configuration file like this > should go on a unix/OS X system? Nothing that I know of. It's quite common for Rails apps to have a config/ directory, so maybe the unicorn config file is suitable there... From patrick at collinatorstudios.com Thu Feb 23 05:01:25 2012 From: patrick at collinatorstudios.com (Patrick J. Collins) Date: Wed, 22 Feb 2012 21:01:25 -0800 (PST) Subject: using unicorn as a local development server In-Reply-To: <20120223043007.GA20356@dcvr.yhbt.net> References: <20120223043007.GA20356@dcvr.yhbt.net> Message-ID: > You shouldn't even need the logger directive, it goes to stderr by > default so your console will still show it. Hmm that's odd because I noticed as soon as I began using unicorn that I got very little output. For example, running my app and browsing to various pages, this is all I see: I, [2012-02-22T19:38:30.511485 #8933] INFO -- : listening on addr=0.0.0.0:3000 fd=3 I, [2012-02-22T19:38:30.511938 #8933] INFO -- : worker=0 spawning... I, [2012-02-22T19:38:30.514042 #8933] INFO -- : master process ready I, [2012-02-22T19:38:30.515943 #8934] INFO -- : worker=0 spawned pid=8934 I, [2012-02-22T19:38:30.516671 #8934] INFO -- : Refreshing Gem list DEPRECATION WARNING: Calling set_table_name is deprecated. Please use `self.table_name = 'the_name'` instead. (called from require at /Users/patrick/.rvm/gems/ruby-1.9.2-p290 at global/gems/bundler-1.1.rc.7/lib/bundler/runtime.rb:68) I, [2012-02-22T19:38:56.879509 #8934] INFO -- : worker=0 ready I, [2012-02-22T19:49:22.737427 #8933] INFO -- : SIGWINCH ignored because we're not daemonized I, [2012-02-22T19:49:35.800600 #8933] INFO -- : SIGWINCH ignored because we're not daemonized I, [2012-02-22T20:02:05.792427 #8933] INFO -- : SIGWINCH ignored because we're not daemonized I, [2012-02-22T20:03:07.315092 #8933] INFO -- : SIGWINCH ignored because we're not daemonized I, [2012-02-22T20:03:36.330349 #8933] INFO -- : SIGWINCH ignored because we're not daemonized I, [2012-02-22T20:04:33.278243 #8933] INFO -- : SIGWINCH ignored because we're not daemonized I, [2012-02-22T20:05:33.188828 #8933] INFO -- : SIGWINCH ignored because we're not daemonized ... None of the development.log output is getting piped into this, so that's why I thought doing the Logger.new(STDOUT) would get that behavior to happen just as it does with the default rails server. Patrick J. Collins http://collinatorstudios.com From normalperson at yhbt.net Thu Feb 23 05:19:54 2012 From: normalperson at yhbt.net (Eric Wong) Date: Thu, 23 Feb 2012 05:19:54 +0000 Subject: using unicorn as a local development server In-Reply-To: References: <20120223043007.GA20356@dcvr.yhbt.net> Message-ID: <20120223051953.GA31014@dcvr.yhbt.net> "Patrick J. Collins" wrote: > > You shouldn't even need the logger directive, it goes to stderr by > > default so your console will still show it. > > Hmm that's odd because I noticed as soon as I began using unicorn that I got > very little output. For example, running my app and browsing to various pages, this is all I see: > None of the development.log output is getting piped into this, so that's why I > thought doing the Logger.new(STDOUT) would get that behavior to happen just as > it does with the default rails server. Odd, not sure what Rails is doing (I don't normally use Rails). It must be something weird with the way Rails modifies all existing logger objects (I know it clobbers the default logger formatter somehow as mentioned in the FAQ). Oh well, I suppose your workaround is as good as any. From ajsharp at gmail.com Thu Feb 23 05:49:48 2012 From: ajsharp at gmail.com (Alex Sharp) Date: Wed, 22 Feb 2012 21:49:48 -0800 Subject: using unicorn as a local development server In-Reply-To: <20120223051953.GA31014@dcvr.yhbt.net> References: <20120223043007.GA20356@dcvr.yhbt.net> <20120223051953.GA31014@dcvr.yhbt.net> Message-ID: > "Patrick J. Collins" wrote: > > Hmm that's odd because I noticed as soon as I began using unicorn that I got > > very little output. For example, running my app and browsing to various pages, this is all I see: > Rails logs to a file by default, so you probably need to set the Rails logger somewhere in your config: Rails.logger = ::Logger.new($stdout) -- Alex Sharp Zaarly, Inc | @ajsharp | github.com/ajsharp | alexjsharp.com From matt at nearapogee.com Fri Feb 24 17:43:28 2012 From: matt at nearapogee.com (Matt Smith) Date: Fri, 24 Feb 2012 09:43:28 -0800 Subject: using unicorn as a local development server Message-ID: > Normally I just write integration tests (sometimes starting unicorn (or > zbatery) + hitting it with curl, but often just mocking a Rack env). > Unlike most folks that develop apps that run over HTTP, I have a strong > aversion to web browsers. I'd rather pipe curl output to "vim -" if I > have to look at any text output from the application. This is slightly off topic, so I will make this concise, or this can be taken offline. What you are talking about, Eric, is exactly the workflow I am working toward. I am almost there, but still too dependent on the browser. So 2 questions: 1) Would you share what you use for integrations tests for rails and rack apps in general? (rack test, minitest, capybara, etc.) 2) Are there any resources you would point to going into further detail? Feel free to respond here or directly, as this is a tangent. Thanks, Matt From patrick at collinatorstudios.com Fri Feb 24 18:47:46 2012 From: patrick at collinatorstudios.com (Patrick J. Collins) Date: Fri, 24 Feb 2012 10:47:46 -0800 (PST) Subject: using unicorn as a local development server In-Reply-To: References: Message-ID: Hi, No one else really replied on this--- But I am wondering if anyone can tell me how I can get my rails development log to stream (as in tail -f) into the unicorn server output... I thought I needed to do logger = Logger.new(STDOUT) in my config file, but that doesn't seem to do it. Any ideas? Patrick J. Collins http://collinatorstudios.com On Wed, 22 Feb 2012, Patrick J. Collins wrote: > Hi Unicorn friends, > > I wanted to try out Unicorn as my development server and I see that I > need to perform some configuration to make this work nicely with rails. > From what I can tell the only real things I need to do to make unicorn > similar to the default rails server is to supply a config file with: > > listen 3000 > logger Logger.new(STDOUT) > > ... > > After creating this file, I was kind of confused as to how to proceed.. > Should I made a bash alias like > > alias unicorn="unicorn_rails -c /path/to/unicorn_config.rb" > > and lastly, is there a convention where a configuration file like this > should go on a unix/OS X system? > > Thank you kindly. > > Patrick J. Collins > http://collinatorstudios.com > > From ajsharp at gmail.com Fri Feb 24 19:26:23 2012 From: ajsharp at gmail.com (Alex Sharp) Date: Fri, 24 Feb 2012 11:26:23 -0800 Subject: using unicorn as a local development server In-Reply-To: References: Message-ID: Hey Patrick, Sorry, I replied a few days ago but looks like I missed your email on the CC. This should solve it: > "Patrick J. Collins" wrote: > > Hmm that's odd because I noticed as soon as I began using unicorn that I got > > very little output. For example, running my app and browsing to various pages, this is all I see: > Rails logs to a file by default, so you probably need to set the Rails logger somewhere in your config: Rails.logger = ::Logger.new($stdout) -- Alex Sharp Zaarly, Inc | @ajsharp | github.com/ajsharp (http://github.com/ajsharp) | alexjsharp.com (http://alexjsharp.com) From normalperson at yhbt.net Fri Feb 24 23:10:22 2012 From: normalperson at yhbt.net (Eric Wong) Date: Fri, 24 Feb 2012 23:10:22 +0000 Subject: using unicorn as a local development server In-Reply-To: References: Message-ID: <20120224231022.GA13091@dcvr.yhbt.net> Matt Smith wrote: > Eric Wong wrote: > > Normally I just write integration tests (sometimes starting unicorn (or > > zbatery) + hitting it with curl, but often just mocking a Rack env). > > Unlike most folks that develop apps that run over HTTP, I have a strong > > aversion to web browsers. I'd rather pipe curl output to "vim -" if I > > have to look at any text output from the application. > > This is slightly off topic, so I will make this concise, or this can > be taken offline. > > What you are talking about, Eric, is exactly the workflow I am working > toward. I am almost there, but still too dependent on the browser. So > 2 questions: > 1) Would you share what you use for integrations tests for rails and > rack apps in general? (rack test, minitest, capybara, etc.) For Rack apps, I normally use test/unit (minitest in 1.9) + Rack::Mock*. test/test_watcher.rb in raindrops[1] is a public example of that. I don't develop a lot of Rack apps, though. I haven't touched Rails in ages, but last time I used test/unit and some builtin Rails test extensions. If I'm testing within Ruby, I stay with test/unit because it's bundled/maintained with the latest version(s) of Ruby. Back in the day, I know some projects had trouble migrating to Ruby 1.9.1 because rspec wasn't 1.9-compatible at the time (it is now). Back to Unicorn (and Rainbows!) ------------------------------- For testing HTTP servers (or anything that interacts with non-Ruby-components), I'll use scripts in other languages (shell/Perl/awk) and external tools (e.g. curl) to shake out potential bugs. I worry about "self-cancelling" bugs which can be hidden from tests because I didn't understand something (often Ruby itself) well enough. Ruby 1.9 encodings is/was especially confusing to me, so I reached outside of Ruby in many cases. [1] - git clone git://bogomips.org/raindrops [2] - For the few Rack apps I write, almost all of them are APIs or targeted at lynx or curl users. I hate pretty things :) From eike at herzbach.net Tue Feb 28 18:34:05 2012 From: eike at herzbach.net (Eike Herzbach) Date: Tue, 28 Feb 2012 19:34:05 +0100 Subject: Suggestion for improvement of examples/nginx.conf Message-ID: Hi, what do you think about that: diff --git a/examples/nginx.conf b/examples/nginx.conf index cc1038a..5ef43f3 100644 --- a/examples/nginx.conf +++ b/examples/nginx.conf @@ -55,7 +55,7 @@ http { # faster or not than doing compression via nginx. It's easier # to configure it all in one place here for static files and also # to disable gzip for clients who don't get gzip/deflate right. - # There are other other gzip settings that may be needed used to deal with + # There are other gzip settings that may be needed used to deal with # bad clients out there, see http://wiki.nginx.org/NginxHttpGzipModule gzip on; gzip_http_version 1.0; @@ -120,9 +120,9 @@ http { # http://en.wikipedia.org/wiki/X-Forwarded-For proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - # enable this if and only if you use HTTPS, this helps Rack + # enable this if you use HTTPS, this helps Rack # set the proper protocol for doing redirects: - # proxy_set_header X-Forwarded-Proto https; + # proxy_set_header X-Forwarded-Proto $scheme; # pass the Host: header from the client right along so redirects # can be set properly within the Rack application I haven't found an easy way to only set the header if the scheme is https, but I don't see any problems in sending the header for all requests either. Regards, Eike From normalperson at yhbt.net Tue Feb 28 21:01:37 2012 From: normalperson at yhbt.net (Eric Wong) Date: Tue, 28 Feb 2012 13:01:37 -0800 Subject: Suggestion for improvement of examples/nginx.conf In-Reply-To: References: Message-ID: <20120228210136.GA2808@dcvr.yhbt.net> Eike Herzbach wrote: > Hi, > > what do you think about that: > > diff --git a/examples/nginx.conf b/examples/nginx.conf > index cc1038a..5ef43f3 100644 > --- a/examples/nginx.conf > +++ b/examples/nginx.conf > @@ -55,7 +55,7 @@ http { > # faster or not than doing compression via nginx. It's easier > # to configure it all in one place here for static files and also > # to disable gzip for clients who don't get gzip/deflate right. > - # There are other other gzip settings that may be needed used to deal with > + # There are other gzip settings that may be needed used to deal with Obviously correct, will apply. Thanks. > - # enable this if and only if you use HTTPS, this helps Rack > + # enable this if you use HTTPS, this helps Rack > # set the proper protocol for doing redirects: > - # proxy_set_header X-Forwarded-Proto https; > + # proxy_set_header X-Forwarded-Proto $scheme; > > # pass the Host: header from the client right along so redirects > # can be set properly within the Rack application > > I haven't found an easy way to only set the header if the scheme is > https, but I don't see any problems in sending the header for all > requests either. Setting it for all requests uses an extra hash slot and leads to extra method dispatches in Rack (and possibly code elsewhere). I suppose it doesn't matter for most setups, though. How about this? --- a/examples/nginx.conf +++ b/examples/nginx.conf @@ -120,9 +120,9 @@ http { # http://en.wikipedia.org/wiki/X-Forwarded-For proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - # enable this if and only if you use HTTPS, this helps Rack - # set the proper protocol for doing redirects: - # proxy_set_header X-Forwarded-Proto https; + # enable this if you forward HTTPS traffic to unicorn, + # this helps Rack set the proper URL scheme for doing redirects: + # proxy_set_header X-Forwarded-Proto $scheme; # pass the Host: header from the client right along so redirects # can be set properly within the Rack application From graham at darkskills.org.uk Wed Feb 29 14:34:44 2012 From: graham at darkskills.org.uk (Graham Bleach) Date: Wed, 29 Feb 2012 14:34:44 +0000 Subject: [PATCH] Start the server if another user has a PID matching our stale pidfile. Message-ID: If unicorn doesn't get terminated cleanly (for example if the machine has its power interrupted) and the pid in the pidfile gets used by another process, the current unicorn code will exit and not start a server. This tiny patch fixes that behaviour. --- lib/unicorn/http_server.rb | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/lib/unicorn/http_server.rb b/lib/unicorn/http_server.rb index 7d2c623..0c2af5d 100644 --- a/lib/unicorn/http_server.rb +++ b/lib/unicorn/http_server.rb @@ -656,7 +656,7 @@ class Unicorn::HttpServer wpid <= 0 and return Process.kill(0, wpid) wpid - rescue Errno::ESRCH, Errno::ENOENT + rescue Errno::ESRCH, Errno::ENOENT, Errno::EPERM # don't unlink stale pid files, racy without non-portable locking... end -- 1.7.5.4 From normalperson at yhbt.net Wed Feb 29 17:25:59 2012 From: normalperson at yhbt.net (Eric Wong) Date: Wed, 29 Feb 2012 17:25:59 +0000 Subject: [PATCH] Start the server if another user has a PID matching our stale pidfile. In-Reply-To: References: Message-ID: <20120229172559.GA26211@dcvr.yhbt.net> Graham Bleach wrote: > If unicorn doesn't get terminated cleanly (for example if the machine > has its power interrupted) and the pid in the pidfile gets used by > another process, the current unicorn code will exit and not start a > server. This tiny patch fixes that behaviour. Thanks! Acked-by: Eric Wong and pushed to master on git://bogomips.org/unicorn.git