From jm.seo.webinars at gmail.com Mon Feb 1 15:47:29 2010 From: jm.seo.webinars at gmail.com (J. McDonald) Date: Mon, 01 Feb 2010 12:47:29 -0800 Subject: Get to the Top of Google: 10 Free SEO Tools (free webinar) Message-ID: Hi, If you're going to keep just one New Year's Resolution, that one should be to get your business SEO fit. (SEO = Search Engine Optimization) Getting physically fit means more exercise and a better diet, getting SEO fit for Google, Yahoo, and Bing means more time identifying your best keywords, more time adding good page tags, and more time building useful links ... To sign up - and find out more details on the class I am teaching - http://www.mobont.com/1/3.html Topics covered in the free SEO Tools webinar and my upcoming full 7-session course (which does require payment) include: * Page Tags - HTML tags that Google/search-engines prefer * Keywords - the key terms and phrases you should have * Website structure - the best website structure for search * Rank - determining your Google rank and that of competitors * Metrics - Webmaster tools and Google analytics * Link-building - tools to identify good link targets * News - how to use news to rise to the top of searches People who have taken this course love it. This is true! It is not your father's snoozer of a webinar. It can get pretty technical but I take my 14 years of hi-tech and SEO experience and make it as fun as possible. You may choose not to continue with the paid training; even so I am sure you will find the one-hour commitment well worth it. I hope you can make it. It will be well worth your time! Best regards, J. McDonald -- It's noble to be good. It's nobler to teach others to be good, and less trouble. - Mark Twain http://www.mobont.com/images/b/1.jpg ) contact info ( http://www.mobont.com/stop.html?mongrel-unicorn at rubyforge.org ) update subscriber ( From precision at mj.cz Wed Feb 3 10:03:37 2010 From: precision at mj.cz (Cheap Viagra on www.22-44.cn) Date: Wed, 03 Feb 2010 16:03:37 +0100 Subject: grimm er burge oned bests ellin g mappi st Message-ID: <4B698E8D.5050205@mj.cz> comme ndato ry snash capto rs bully boys ruffl y crene llate d forum ises nippi ness mastu rbati ng conju red tails tock navel s byes hypos hebra izes vulca nisin g enhan cemen ts their giggl e gunk From hukl at berlin.ccc.de Thu Feb 4 03:16:35 2010 From: hukl at berlin.ccc.de (John-Paul Bader) Date: Thu, 4 Feb 2010 09:16:35 +0100 Subject: "upstream timed out" after upgrades Message-ID: Hey guys, i recently updated several components of my website setup: varnish 2.0.5 -> 2.0.6 nginx 7.4.2 -> 7.4.5 unicorn 0.95.3 -> 0.96 ruby18 to the latest patch level and rails from 2.3.2 It all seemed to work great but recently I noticed that the website hangs loading. The weird thing is that it hangs because 2 or 3 javascript files take about a minute to finish and when they do they are incomplete as in cut of in the middle of the content. The nginx error log gives the following output every few seconds: 2010/02/04 08:58:41 [error] 29389#0: *471 upstream timed out (60: Operation timed out) while reading upstream, client: 213.73.89.122, server: www.ccc.de, request: "GET /javascripts/jquery-1.3.2.min.js?1246657683 HTTP/1.1", upstream: "http://unix:/var/run/unicorn.sock:/javascripts/jquery-1.3.2.min.js?1246657683", host: "www.ccc.de" I don't think its varnishs fault because i get Internal Server Errors (500) if I run curl on the machine against nginx, not at first though - several requests for that jquery file run just fine and then suddenly i get a 500 on a request with the content being cut of in the middle. Next thing I did was configuring unicorn to listen on 213.73.89.122:9090 rather than on a socket so i could run curl directly against it and even after a fresh start of unicorn gives me: curl http://213.73.89.122:9090/javascripts/jquery-1.3.2.min.js (lots of javascript)?,rowspan:"rowSpan",tabindex:"tabIndHTTP/1.1 500 Internal Server Error curl: (18) transfer closed with 16256 bytes remaining to read I also downgraded back to 0.95.3 but that didn't change anything. So now after 8h of try and error I'm out of ideas and would be happy to hear some suggestions. Kind regards, John From hukl at h3q.com Thu Feb 4 03:48:50 2010 From: hukl at h3q.com (John-Paul Bader) Date: Thu, 4 Feb 2010 09:48:50 +0100 Subject: "upstream timed out" after upgrades In-Reply-To: References: Message-ID: <5D2B92C5-8D0A-4810-B86B-06F670C6EFDB@h3q.com> Hrm its getting weirder and weirder. I started unicorn_rails now manually in the app root which is now running on rails 2.3.3 again: sudo unicorn_rails -E production -d -c /usr/local/etc/unicorn.rb Now first of all it throws lots of Exceptions it couldn't find several (important) gems and then it produces this every second or so: Exception `Errno::EAGAIN' at /usr/local/lib/ruby/gems/1.8/gems/unicorn-0.95.3/lib/unicorn.rb:640 - Resource temporarily unavailable - accept(2) When I request the javascript in question I get: Exception `Errno::EINVAL' at /usr/local/lib/ruby/gems/1.8/gems/unicorn-0.95.3/lib/unicorn/http_response.rb:67 - Invalid argument Exception `Errno::EAGAIN' at /usr/local/lib/ruby/gems/1.8/gems/unicorn-0.95.3/lib/unicorn.rb:640 - Resource temporarily unavailable - accept(2) This is the same no matter if I run it with -c or not. I am puzzled. To give you the entire output of unicorn starting: [hukl at cccms /usr/local/www/cccms]$ sudo unicorn_rails -E production -d -p 9090 {:daemonize=>false, :unicorn_options=>{:listeners=>["0.0.0.0:9090"]}, :app=> #} Exception `Errno::EEXIST' at /usr/local/lib/ruby/1.8/fileutils.rb:243 - File exists - tmp/cache Exception `Errno::EEXIST' at /usr/local/lib/ruby/1.8/fileutils.rb:243 - File exists - tmp/pids Exception `Errno::EEXIST' at /usr/local/lib/ruby/1.8/fileutils.rb:243 - File exists - tmp/sessions Exception `Errno::EEXIST' at /usr/local/lib/ruby/1.8/fileutils.rb:243 - File exists - tmp/sockets I, [2010-02-04T09:42:08.141034 #38499] INFO -- : listening on addr=213.73.89.122:9090 fd=3 Exception `LoadError' at /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31 - no such file to load -- Win32API Exception `LoadError' at /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:38 - no such file to load -- Win32API I, [2010-02-04T09:42:08.158275 #38499] INFO -- : worker=0 spawning... I, [2010-02-04T09:42:08.159352 #38499] INFO -- : master process ready I, [2010-02-04T09:42:08.159471 #38501] INFO -- : worker=0 spawned pid=38501 I, [2010-02-04T09:42:08.197082 #38501] INFO -- : Refreshing Gem list Exception `Gem::LoadError' at /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:827 - Could not find RubyGem builder (~> 2.1.2) Exception `Gem::LoadError' at /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:827 - Could not find RubyGem memcache-client (>= 1.7.4) Exception `Gem::LoadError' at /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:827 - Could not find RubyGem tzinfo (~> 0.3.12) Exception `Gem::LoadError' at /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:827 - Could not find RubyGem i18n (~> 0.1.3) Exception `TypeError' at (eval):4 - can't modify frozen object Exception `MissingSourceFile' at /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31 - no such file to load -- fast_xs Exception `MissingSourceFile' at /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31 - no such file to load -- json Using c extension for JSON. Exception `Gem::LoadError' at /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:827 - Could not find RubyGem tmail (~> 1.2.3) Exception `MissingSourceFile' at /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31 - no such file to load -- tmail/tmailscanner Exception `MissingSourceFile' at /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:38 - no such file to load -- tmail/tmailscanner Exception `MissingSourceFile' at /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:162 - no such file to load -- tmail/tmailscanner Exception `Gem::LoadError' at /usr/local/lib/ruby/site_ruby/1.8/rubygems.rb:827 - Could not find RubyGem activerecord-postgresql-adapter (>= 0) Exception `MissingSourceFile' at /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31 - no such file to load -- pg WARNING: Nokogiri was built against LibXML version 2.7.3, but has dynamically loaded 2.7.6 Exception `MissingSourceFile' at /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31 - no such file to load -- ruby-debug Exception `MissingSourceFile' at /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31 - no such file to load -- classtree Exception `MissingSourceFile' at /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:38 - no such file to load -- classtree Exception `MissingSourceFile' at /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:162 - no such file to load -- classtree Exception `MissingSourceFile' at /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31 - no such file to load -- methodsig Exception `MissingSourceFile' at /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:38 - no such file to load -- methodsig Exception `MissingSourceFile' at /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.3.3/lib/active_support/dependencies.rb:162 - no such file to load -- methodsig => Debugger enabled worker=0 ready Exception `Errno::EAGAIN' at /usr/local/lib/ruby/gems/1.8/gems/unicorn-0.95.3/lib/unicorn.rb:640 - Resource temporarily unavailable - accept(2) Exception `Errno::EINVAL' at /usr/local/lib/ruby/gems/1.8/gems/unicorn-0.95.3/lib/unicorn/http_response.rb:67 - Invalid argument Exception `Errno::EAGAIN' at /usr/local/lib/ruby/gems/1.8/gems/unicorn-0.95.3/lib/unicorn.rb:640 - Resource temporarily unavailable - accept(2) Exception `Errno::EINVAL' at /usr/local/lib/ruby/gems/1.8/gems/unicorn-0.95.3/lib/unicorn/http_response.rb:67 - Invalid argument Exception `Errno::EAGAIN' at /usr/local/lib/ruby/gems/1.8/gems/unicorn-0.95.3/lib/unicorn.rb:640 - Resource temporarily unavailable - accept(2) Exception `Errno::EINVAL' at /usr/local/lib/ruby/gems/1.8/gems/unicorn-0.95.3/lib/unicorn/http_response.rb:67 - Invalid argument Exception `Errno::EAGAIN' at /usr/local/lib/ruby/gems/1.8/gems/unicorn-0.95.3/lib/unicorn.rb:640 - Resource temporarily unavailable - accept(2) I seriously have no idea went wrong - It ran all so smooth couple of days ago. What am I missing - there must be something plain wrong. I left the js files out of the public site for now - it isn't needed that much and its more important to serve the content for now. In case you are trying to get it. Kind regards, John On 04.02.2010, at 09:16, John-Paul Bader wrote: > Hey guys, > > > i recently updated several components of my website setup: > > varnish 2.0.5 -> 2.0.6 > nginx 7.4.2 -> 7.4.5 > unicorn 0.95.3 -> 0.96 > ruby18 to the latest patch level > and rails from 2.3.2 > > It all seemed to work great but recently I noticed that the website hangs loading. The weird thing is that it hangs because 2 or 3 javascript files take about a minute to finish and when they do they are incomplete as in cut of in the middle of the content. The nginx error log gives the following output every few seconds: > > 2010/02/04 08:58:41 [error] 29389#0: *471 upstream timed out (60: Operation timed out) while reading upstream, client: 213.73.89.122, server: www.ccc.de, request: "GET /javascripts/jquery-1.3.2.min.js?1246657683 HTTP/1.1", upstream: "http://unix:/var/run/unicorn.sock:/javascripts/jquery-1.3.2.min.js?1246657683", host: "www.ccc.de" > > I don't think its varnishs fault because i get Internal Server Errors (500) if I run curl on the machine against nginx, not at first though - several requests for that jquery file run just fine and then suddenly i get a 500 on a request with the content being cut of in the middle. > > Next thing I did was configuring unicorn to listen on 213.73.89.122:9090 rather than on a socket so i could run curl directly against it and even after a fresh start of unicorn gives me: > > > curl http://213.73.89.122:9090/javascripts/jquery-1.3.2.min.js > (lots of javascript)?,rowspan:"rowSpan",tabindex:"tabIndHTTP/1.1 500 Internal Server Error > > curl: (18) transfer closed with 16256 bytes remaining to read > > I also downgraded back to 0.95.3 but that didn't change anything. So now after 8h of try and error I'm out of ideas and would be happy to hear some suggestions. > > Kind regards, John > _______________________________________________ > Unicorn mailing list - mongrel-unicorn at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-unicorn > Do not quote signatures (like this one) or top post when replying > From hukl at h3q.com Thu Feb 4 04:28:54 2010 From: hukl at h3q.com (John-Paul Bader) Date: Thu, 4 Feb 2010 10:28:54 +0100 Subject: "upstream timed out" after upgrades In-Reply-To: <5D2B92C5-8D0A-4810-B86B-06F670C6EFDB@h3q.com> References: <5D2B92C5-8D0A-4810-B86B-06F670C6EFDB@h3q.com> Message-ID: <9D7E3DD2-4CE3-45FA-8383-34E33BCDA5C4@h3q.com> One more, I reproduced the upgrading on my staging server which was still at the old state in terms of software. I started by upgrading ruby from ruby+nopthreads-1.8.7.160_5,1 -> ruby+nopthreads-1.8.7.248,1 ruby18-iconv-1.8.7.160,1 -> ruby18-iconv-1.8.7.248,1 And voil? - the very same problems. So now I'm like what? Is this rather a ruby than a unicorn issue ? Couldn't find any clues in the changelog so far: http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/tags/v1_8_7_248/ChangeLog Kind regards, John From normalperson at yhbt.net Thu Feb 4 05:11:49 2010 From: normalperson at yhbt.net (Eric Wong) Date: Thu, 4 Feb 2010 02:11:49 -0800 Subject: "upstream timed out" after upgrades In-Reply-To: <9D7E3DD2-4CE3-45FA-8383-34E33BCDA5C4@h3q.com> References: <5D2B92C5-8D0A-4810-B86B-06F670C6EFDB@h3q.com> <9D7E3DD2-4CE3-45FA-8383-34E33BCDA5C4@h3q.com> Message-ID: <20100204101149.GA14864@dcvr.yhbt.net> John-Paul Bader wrote: > One more, Hi, About the exceptions, looks like you had '-d' (debug) instead of '-D' (daemonize) so it spewed every exception (even if trapped) to stderr. EAGAIN is common when dealing with non-blocking sockets. Most of that is noise... However the EINVAL in unicorn/http_response.rb is suspect. > I reproduced the upgrading on my staging server which was still at the > old state in terms of software. I started by upgrading ruby from > > ruby+nopthreads-1.8.7.160_5,1 -> ruby+nopthreads-1.8.7.248,1 > ruby18-iconv-1.8.7.160,1 -> ruby18-iconv-1.8.7.248,1 > > And voil? - the very same problems. So now I'm like what? > > Is this rather a ruby than a unicorn issue ? Couldn't find any clues > in the changelog so far: > http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/tags/v1_8_7_248/ChangeLog That should narrow it down, so I start reading diffs from v1_8_7_160..v1_8_7_248 ... Does backporting the following change in ruby_1_8 (but not yet in the ruby_1_8_7 branch) fix things for you? commit 841a57341ed43f5fa86489c12aceb25a232be820 Author: nobu Date: Fri Jan 8 09:51:23 2010 +0000 * io.c (io_fwrite): preserve errno. [ruby-core:27425] git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8 at 26253 (snipped) diff --git a/io.c b/io.c index 375cbc8..d4d28e5 100644 --- a/io.c +++ b/io.c @@ -122,6 +122,9 @@ extern void Init_File _((void)); # endif #endif +#define preserving_errno(stmts) \ + do {int saved_errno = errno; stmts; errno = saved_errno;} while (0) + VALUE rb_cIO; VALUE rb_eEOFError; VALUE rb_eIOError; @@ -490,7 +493,7 @@ io_fwrite(str, fptr) r = write(fileno(f), RSTRING(str)->ptr+offset, l); TRAP_END; #if BSD_STDIO - fseeko(f, lseek(fileno(f), (off_t)0, SEEK_CUR), SEEK_SET); + preserving_errno(fseeko(f, lseek(fileno(f), (off_t)0, SEEK_CUR), SEEK_SET)); #endif if (r == n) return len; if (0 <= r) { --- Of course, the original reason for this fseeko() was to fix another problem Unicorn exposed when mixing stdio + unistd calls... http://redmine.ruby-lang.org/issues/show/2267 -- Eric Wong From hukl at h3q.com Thu Feb 4 07:26:23 2010 From: hukl at h3q.com (John-Paul Bader) Date: Thu, 4 Feb 2010 13:26:23 +0100 Subject: "upstream timed out" after upgrades In-Reply-To: <20100204101149.GA14864@dcvr.yhbt.net> References: <5D2B92C5-8D0A-4810-B86B-06F670C6EFDB@h3q.com> <9D7E3DD2-4CE3-45FA-8383-34E33BCDA5C4@h3q.com> <20100204101149.GA14864@dcvr.yhbt.net> Message-ID: <9170C06E-85E6-428A-A5E5-56AF9379AD41@h3q.com> Hey again, I will try to compile build the svn revision and let you know. I have to do some other work before that so I will report back in the evening (CEST / BERLIN) Thank you for helping out, kind regards, John On 04.02.2010, at 11:11, Eric Wong wrote: > John-Paul Bader wrote: >> One more, > > Hi, > > About the exceptions, looks like you had '-d' (debug) instead of '-D' > (daemonize) so it spewed every exception (even if trapped) to stderr. > EAGAIN is common when dealing with non-blocking sockets. Most of that > is noise... > > However the EINVAL in unicorn/http_response.rb is suspect. > >> I reproduced the upgrading on my staging server which was still at the >> old state in terms of software. I started by upgrading ruby from >> >> ruby+nopthreads-1.8.7.160_5,1 -> ruby+nopthreads-1.8.7.248,1 >> ruby18-iconv-1.8.7.160,1 -> ruby18-iconv-1.8.7.248,1 >> >> And voil? - the very same problems. So now I'm like what? >> >> Is this rather a ruby than a unicorn issue ? Couldn't find any clues >> in the changelog so far: >> http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/tags/v1_8_7_248/ChangeLog > > That should narrow it down, so I start reading diffs from > v1_8_7_160..v1_8_7_248 ... > > Does backporting the following change in ruby_1_8 > (but not yet in the ruby_1_8_7 branch) fix things for you? > > commit 841a57341ed43f5fa86489c12aceb25a232be820 > Author: nobu > Date: Fri Jan 8 09:51:23 2010 +0000 > > * io.c (io_fwrite): preserve errno. [ruby-core:27425] > > > git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8 at 26253 > > (snipped) > > diff --git a/io.c b/io.c > index 375cbc8..d4d28e5 100644 > --- a/io.c > +++ b/io.c > @@ -122,6 +122,9 @@ extern void Init_File _((void)); > # endif > #endif > > +#define preserving_errno(stmts) \ > + do {int saved_errno = errno; stmts; errno = saved_errno;} while (0) > + > VALUE rb_cIO; > VALUE rb_eEOFError; > VALUE rb_eIOError; > @@ -490,7 +493,7 @@ io_fwrite(str, fptr) > r = write(fileno(f), RSTRING(str)->ptr+offset, l); > TRAP_END; > #if BSD_STDIO > - fseeko(f, lseek(fileno(f), (off_t)0, SEEK_CUR), SEEK_SET); > + preserving_errno(fseeko(f, lseek(fileno(f), (off_t)0, SEEK_CUR), SEEK_SET)); > #endif > if (r == n) return len; > if (0 <= r) { > --- > Of course, the original reason for this fseeko() was to fix another > problem Unicorn exposed when mixing stdio + unistd calls... > > http://redmine.ruby-lang.org/issues/show/2267 > > -- > Eric Wong > _______________________________________________ > Unicorn mailing list - mongrel-unicorn at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-unicorn > Do not quote signatures (like this one) or top post when replying > From hukl at berlin.ccc.de Thu Feb 4 09:22:15 2010 From: hukl at berlin.ccc.de (John-Paul Bader) Date: Thu, 4 Feb 2010 15:22:15 +0100 Subject: "upstream timed out" after upgrades In-Reply-To: <9170C06E-85E6-428A-A5E5-56AF9379AD41@h3q.com> References: <5D2B92C5-8D0A-4810-B86B-06F670C6EFDB@h3q.com> <9D7E3DD2-4CE3-45FA-8383-34E33BCDA5C4@h3q.com> <20100204101149.GA14864@dcvr.yhbt.net> <9170C06E-85E6-428A-A5E5-56AF9379AD41@h3q.com> Message-ID: <2F0B8521-F568-4C68-B59C-1173203CE4E3@berlin.ccc.de> Hey, i checked out the revision 26253 built it and ran it and it seems to work again but: I didn't build it via FreeBSD ports so there might be a difference in configure / build options and I checked out the revision which included the change you suspect for causing the issue so I'm not sure if thats really helping us. Curling directly unicorn works without truncation and issues though. Kind regards, John On 04.02.2010, at 13:26, John-Paul Bader wrote: > Hey again, > > I will try to compile build the svn revision and let you know. I have to do some other work before that so I will report back in the evening (CEST / BERLIN) > > Thank you for helping out, kind regards, > > John > > On 04.02.2010, at 11:11, Eric Wong wrote: > >> John-Paul Bader wrote: >>> One more, >> >> Hi, >> >> About the exceptions, looks like you had '-d' (debug) instead of '-D' >> (daemonize) so it spewed every exception (even if trapped) to stderr. >> EAGAIN is common when dealing with non-blocking sockets. Most of that >> is noise... >> >> However the EINVAL in unicorn/http_response.rb is suspect. >> >>> I reproduced the upgrading on my staging server which was still at the >>> old state in terms of software. I started by upgrading ruby from >>> >>> ruby+nopthreads-1.8.7.160_5,1 -> ruby+nopthreads-1.8.7.248,1 >>> ruby18-iconv-1.8.7.160,1 -> ruby18-iconv-1.8.7.248,1 >>> >>> And voil? - the very same problems. So now I'm like what? >>> >>> Is this rather a ruby than a unicorn issue ? Couldn't find any clues >>> in the changelog so far: >>> http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/tags/v1_8_7_248/ChangeLog >> >> That should narrow it down, so I start reading diffs from >> v1_8_7_160..v1_8_7_248 ... >> >> Does backporting the following change in ruby_1_8 >> (but not yet in the ruby_1_8_7 branch) fix things for you? >> >> commit 841a57341ed43f5fa86489c12aceb25a232be820 >> Author: nobu >> Date: Fri Jan 8 09:51:23 2010 +0000 >> >> * io.c (io_fwrite): preserve errno. [ruby-core:27425] >> >> >> git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8 at 26253 >> >> (snipped) >> >> diff --git a/io.c b/io.c >> index 375cbc8..d4d28e5 100644 >> --- a/io.c >> +++ b/io.c >> @@ -122,6 +122,9 @@ extern void Init_File _((void)); >> # endif >> #endif >> >> +#define preserving_errno(stmts) \ >> + do {int saved_errno = errno; stmts; errno = saved_errno;} while (0) >> + >> VALUE rb_cIO; >> VALUE rb_eEOFError; >> VALUE rb_eIOError; >> @@ -490,7 +493,7 @@ io_fwrite(str, fptr) >> r = write(fileno(f), RSTRING(str)->ptr+offset, l); >> TRAP_END; >> #if BSD_STDIO >> - fseeko(f, lseek(fileno(f), (off_t)0, SEEK_CUR), SEEK_SET); >> + preserving_errno(fseeko(f, lseek(fileno(f), (off_t)0, SEEK_CUR), SEEK_SET)); >> #endif >> if (r == n) return len; >> if (0 <= r) { >> --- >> Of course, the original reason for this fseeko() was to fix another >> problem Unicorn exposed when mixing stdio + unistd calls... >> >> http://redmine.ruby-lang.org/issues/show/2267 >> >> -- >> Eric Wong >> _______________________________________________ >> Unicorn mailing list - mongrel-unicorn at rubyforge.org >> http://rubyforge.org/mailman/listinfo/mongrel-unicorn >> Do not quote signatures (like this one) or top post when replying >> > > _______________________________________________ > Unicorn mailing list - mongrel-unicorn at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-unicorn > Do not quote signatures (like this one) or top post when replying > From hukl at h3q.com Thu Feb 4 10:11:19 2010 From: hukl at h3q.com (John-Paul Bader) Date: Thu, 4 Feb 2010 16:11:19 +0100 Subject: "upstream timed out" after upgrades In-Reply-To: <2F0B8521-F568-4C68-B59C-1173203CE4E3@berlin.ccc.de> References: <5D2B92C5-8D0A-4810-B86B-06F670C6EFDB@h3q.com> <9D7E3DD2-4CE3-45FA-8383-34E33BCDA5C4@h3q.com> <20100204101149.GA14864@dcvr.yhbt.net> <9170C06E-85E6-428A-A5E5-56AF9379AD41@h3q.com> <2F0B8521-F568-4C68-B59C-1173203CE4E3@berlin.ccc.de> Message-ID: <40336AA2-17B7-433B-BCFA-30B172365781@h3q.com> To counter check I just built the latest ruby from source as well and the issue reappeared - so it happened between 26253 and tag/248 Kind regards, John On 04.02.2010, at 15:22, John-Paul Bader wrote: > Hey, > > i checked out the revision 26253 built it and ran it and it seems to work again but: I didn't build it via FreeBSD ports so there might be a difference in configure / build options and I checked out the revision which included the change you suspect for causing the issue so I'm not sure if thats really helping us. Curling directly unicorn works without truncation and issues though. > > Kind regards, John > > On 04.02.2010, at 13:26, John-Paul Bader wrote: > >> Hey again, >> >> I will try to compile build the svn revision and let you know. I have to do some other work before that so I will report back in the evening (CEST / BERLIN) >> >> Thank you for helping out, kind regards, >> >> John >> >> On 04.02.2010, at 11:11, Eric Wong wrote: >> >>> John-Paul Bader wrote: >>>> One more, >>> >>> Hi, >>> >>> About the exceptions, looks like you had '-d' (debug) instead of '-D' >>> (daemonize) so it spewed every exception (even if trapped) to stderr. >>> EAGAIN is common when dealing with non-blocking sockets. Most of that >>> is noise... >>> >>> However the EINVAL in unicorn/http_response.rb is suspect. >>> >>>> I reproduced the upgrading on my staging server which was still at the >>>> old state in terms of software. I started by upgrading ruby from >>>> >>>> ruby+nopthreads-1.8.7.160_5,1 -> ruby+nopthreads-1.8.7.248,1 >>>> ruby18-iconv-1.8.7.160,1 -> ruby18-iconv-1.8.7.248,1 >>>> >>>> And voil? - the very same problems. So now I'm like what? >>>> >>>> Is this rather a ruby than a unicorn issue ? Couldn't find any clues >>>> in the changelog so far: >>>> http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/tags/v1_8_7_248/ChangeLog >>> >>> That should narrow it down, so I start reading diffs from >>> v1_8_7_160..v1_8_7_248 ... >>> >>> Does backporting the following change in ruby_1_8 >>> (but not yet in the ruby_1_8_7 branch) fix things for you? >>> >>> commit 841a57341ed43f5fa86489c12aceb25a232be820 >>> Author: nobu >>> Date: Fri Jan 8 09:51:23 2010 +0000 >>> >>> * io.c (io_fwrite): preserve errno. [ruby-core:27425] >>> >>> >>> git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8 at 26253 >>> >>> (snipped) >>> >>> diff --git a/io.c b/io.c >>> index 375cbc8..d4d28e5 100644 >>> --- a/io.c >>> +++ b/io.c >>> @@ -122,6 +122,9 @@ extern void Init_File _((void)); >>> # endif >>> #endif >>> >>> +#define preserving_errno(stmts) \ >>> + do {int saved_errno = errno; stmts; errno = saved_errno;} while (0) >>> + >>> VALUE rb_cIO; >>> VALUE rb_eEOFError; >>> VALUE rb_eIOError; >>> @@ -490,7 +493,7 @@ io_fwrite(str, fptr) >>> r = write(fileno(f), RSTRING(str)->ptr+offset, l); >>> TRAP_END; >>> #if BSD_STDIO >>> - fseeko(f, lseek(fileno(f), (off_t)0, SEEK_CUR), SEEK_SET); >>> + preserving_errno(fseeko(f, lseek(fileno(f), (off_t)0, SEEK_CUR), SEEK_SET)); >>> #endif >>> if (r == n) return len; >>> if (0 <= r) { >>> --- >>> Of course, the original reason for this fseeko() was to fix another >>> problem Unicorn exposed when mixing stdio + unistd calls... >>> >>> http://redmine.ruby-lang.org/issues/show/2267 >>> >>> -- >>> Eric Wong >>> _______________________________________________ >>> Unicorn mailing list - mongrel-unicorn at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/mongrel-unicorn >>> Do not quote signatures (like this one) or top post when replying >>> >> >> _______________________________________________ >> Unicorn mailing list - mongrel-unicorn at rubyforge.org >> http://rubyforge.org/mailman/listinfo/mongrel-unicorn >> Do not quote signatures (like this one) or top post when replying >> > > _______________________________________________ > Unicorn mailing list - mongrel-unicorn at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-unicorn > Do not quote signatures (like this one) or top post when replying > From normalperson at yhbt.net Thu Feb 4 14:42:29 2010 From: normalperson at yhbt.net (Eric Wong) Date: Thu, 4 Feb 2010 19:42:29 +0000 Subject: "upstream timed out" after upgrades In-Reply-To: <40336AA2-17B7-433B-BCFA-30B172365781@h3q.com> References: <5D2B92C5-8D0A-4810-B86B-06F670C6EFDB@h3q.com> <9D7E3DD2-4CE3-45FA-8383-34E33BCDA5C4@h3q.com> <20100204101149.GA14864@dcvr.yhbt.net> <9170C06E-85E6-428A-A5E5-56AF9379AD41@h3q.com> <2F0B8521-F568-4C68-B59C-1173203CE4E3@berlin.ccc.de> <40336AA2-17B7-433B-BCFA-30B172365781@h3q.com> Message-ID: <20100204194228.GA4555@dcvr.yhbt.net> John-Paul Bader wrote: > To counter check I just built the latest ruby from source as well and > the issue reappeared - so it happened between 26253 and tag/248 Keep in mind that 1.8.7-p248 is from the "ruby_1_8_7" branch, not the "ruby_1_8" branch which contains r26253. -- Eric Wong From hukl at berlin.ccc.de Thu Feb 4 15:01:51 2010 From: hukl at berlin.ccc.de (John-Paul Bader) Date: Thu, 4 Feb 2010 21:01:51 +0100 Subject: "upstream timed out" after upgrades In-Reply-To: <20100204194228.GA4555@dcvr.yhbt.net> References: <5D2B92C5-8D0A-4810-B86B-06F670C6EFDB@h3q.com> <9D7E3DD2-4CE3-45FA-8383-34E33BCDA5C4@h3q.com> <20100204101149.GA14864@dcvr.yhbt.net> <9170C06E-85E6-428A-A5E5-56AF9379AD41@h3q.com> <2F0B8521-F568-4C68-B59C-1173203CE4E3@berlin.ccc.de> <40336AA2-17B7-433B-BCFA-30B172365781@h3q.com> <20100204194228.GA4555@dcvr.yhbt.net> Message-ID: Hmm I see, kind of ;) Do you have a clue what is going wrong or any other things I could check out ? Kind regards, John On 04.02.2010, at 20:42, Eric Wong wrote: > John-Paul Bader wrote: >> To counter check I just built the latest ruby from source as well and >> the issue reappeared - so it happened between 26253 and tag/248 > > Keep in mind that 1.8.7-p248 is from the "ruby_1_8_7" branch, not the > "ruby_1_8" branch which contains r26253. > > -- > Eric Wong > _______________________________________________ > Unicorn mailing list - mongrel-unicorn at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-unicorn > Do not quote signatures (like this one) or top post when replying > From normalperson at yhbt.net Thu Feb 4 15:14:55 2010 From: normalperson at yhbt.net (Eric Wong) Date: Thu, 4 Feb 2010 20:14:55 +0000 Subject: "upstream timed out" after upgrades In-Reply-To: References: <5D2B92C5-8D0A-4810-B86B-06F670C6EFDB@h3q.com> <9D7E3DD2-4CE3-45FA-8383-34E33BCDA5C4@h3q.com> <20100204101149.GA14864@dcvr.yhbt.net> <9170C06E-85E6-428A-A5E5-56AF9379AD41@h3q.com> <2F0B8521-F568-4C68-B59C-1173203CE4E3@berlin.ccc.de> <40336AA2-17B7-433B-BCFA-30B172365781@h3q.com> <20100204194228.GA4555@dcvr.yhbt.net> Message-ID: <20100204201455.GA11834@dcvr.yhbt.net> John-Paul Bader wrote: > Hmm I see, kind of ;) > > Do you have a clue what is going wrong or any other things I could > check out ? Can you just backport the r26253 change into your 1.8.7-p248 installation? (see the patch in the previous email). I'm fairly certain that's it based on the EINVAL. -- Eric Wong From hukl at h3q.com Thu Feb 4 15:23:27 2010 From: hukl at h3q.com (John-Paul Bader) Date: Thu, 4 Feb 2010 21:23:27 +0100 Subject: "upstream timed out" after upgrades In-Reply-To: <20100204201455.GA11834@dcvr.yhbt.net> References: <5D2B92C5-8D0A-4810-B86B-06F670C6EFDB@h3q.com> <9D7E3DD2-4CE3-45FA-8383-34E33BCDA5C4@h3q.com> <20100204101149.GA14864@dcvr.yhbt.net> <9170C06E-85E6-428A-A5E5-56AF9379AD41@h3q.com> <2F0B8521-F568-4C68-B59C-1173203CE4E3@berlin.ccc.de> <40336AA2-17B7-433B-BCFA-30B172365781@h3q.com> <20100204194228.GA4555@dcvr.yhbt.net> <20100204201455.GA11834@dcvr.yhbt.net> Message-ID: I can of course, however I'd rather have an off the shelf ruby version out of the ports tree. But if there is currently no other way to fix this issue I will of course. I wonder if this issue always appears on ruby1.9. I will check that out too. Kind regards, John On 04.02.2010, at 21:14, Eric Wong wrote: > John-Paul Bader wrote: >> Hmm I see, kind of ;) >> >> Do you have a clue what is going wrong or any other things I could >> check out ? > > Can you just backport the r26253 change into your 1.8.7-p248 > installation? (see the patch in the previous email). I'm fairly > certain that's it based on the EINVAL. > > -- > Eric Wong > _______________________________________________ > Unicorn mailing list - mongrel-unicorn at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-unicorn > Do not quote signatures (like this one) or top post when replying > From hukl at h3q.com Thu Feb 4 15:27:08 2010 From: hukl at h3q.com (John-Paul Bader) Date: Thu, 4 Feb 2010 21:27:08 +0100 Subject: "upstream timed out" after upgrades In-Reply-To: <20100204201455.GA11834@dcvr.yhbt.net> References: <5D2B92C5-8D0A-4810-B86B-06F670C6EFDB@h3q.com> <9D7E3DD2-4CE3-45FA-8383-34E33BCDA5C4@h3q.com> <20100204101149.GA14864@dcvr.yhbt.net> <9170C06E-85E6-428A-A5E5-56AF9379AD41@h3q.com> <2F0B8521-F568-4C68-B59C-1173203CE4E3@berlin.ccc.de> <40336AA2-17B7-433B-BCFA-30B172365781@h3q.com> <20100204194228.GA4555@dcvr.yhbt.net> <20100204201455.GA11834@dcvr.yhbt.net> Message-ID: Hmm, my C skills are really weak but this patch suppresses any IO errors right? At least on BSD? Can you explain what exactly it is doing? Just want to understand entirely. I thought your diff was the ruby diff of r26253 and didn't realize it was yours ;) Kind regards, John On 04.02.2010, at 21:14, Eric Wong wrote: > John-Paul Bader wrote: >> Hmm I see, kind of ;) >> >> Do you have a clue what is going wrong or any other things I could >> check out ? > > Can you just backport the r26253 change into your 1.8.7-p248 > installation? (see the patch in the previous email). I'm fairly > certain that's it based on the EINVAL. > > -- > Eric Wong > _______________________________________________ > Unicorn mailing list - mongrel-unicorn at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-unicorn > Do not quote signatures (like this one) or top post when replying > From hukl at h3q.com Thu Feb 4 15:48:22 2010 From: hukl at h3q.com (John-Paul Bader) Date: Thu, 4 Feb 2010 21:48:22 +0100 Subject: "upstream timed out" after upgrades In-Reply-To: References: <5D2B92C5-8D0A-4810-B86B-06F670C6EFDB@h3q.com> <9D7E3DD2-4CE3-45FA-8383-34E33BCDA5C4@h3q.com> <20100204101149.GA14864@dcvr.yhbt.net> <9170C06E-85E6-428A-A5E5-56AF9379AD41@h3q.com> <2F0B8521-F568-4C68-B59C-1173203CE4E3@berlin.ccc.de> <40336AA2-17B7-433B-BCFA-30B172365781@h3q.com> <20100204194228.GA4555@dcvr.yhbt.net> <20100204201455.GA11834@dcvr.yhbt.net> Message-ID: Sorry one more: Is this something you will address sooner or later or is this a "ruby on bsd" bug? Kind regards, John From hukl at h3q.com Thu Feb 4 16:05:34 2010 From: hukl at h3q.com (John-Paul Bader) Date: Thu, 4 Feb 2010 22:05:34 +0100 Subject: "upstream timed out" after upgrades In-Reply-To: References: <5D2B92C5-8D0A-4810-B86B-06F670C6EFDB@h3q.com> <9D7E3DD2-4CE3-45FA-8383-34E33BCDA5C4@h3q.com> <20100204101149.GA14864@dcvr.yhbt.net> <9170C06E-85E6-428A-A5E5-56AF9379AD41@h3q.com> <2F0B8521-F568-4C68-B59C-1173203CE4E3@berlin.ccc.de> <40336AA2-17B7-433B-BCFA-30B172365781@h3q.com> <20100204194228.GA4555@dcvr.yhbt.net> <20100204201455.GA11834@dcvr.yhbt.net> Message-ID: <66D67C93-D990-455B-985E-AB93AB786A61@h3q.com> One more ;) Backporting on p248 fixed it. Thanks, John On 04.02.2010, at 21:48, John-Paul Bader wrote: > Sorry one more: > > Is this something you will address sooner or later or is this a "ruby on bsd" bug? > > Kind regards, John > _______________________________________________ > Unicorn mailing list - mongrel-unicorn at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-unicorn > Do not quote signatures (like this one) or top post when replying > From normalperson at yhbt.net Thu Feb 4 16:25:34 2010 From: normalperson at yhbt.net (Eric Wong) Date: Thu, 4 Feb 2010 13:25:34 -0800 Subject: "upstream timed out" after upgrades In-Reply-To: References: <9D7E3DD2-4CE3-45FA-8383-34E33BCDA5C4@h3q.com> <20100204101149.GA14864@dcvr.yhbt.net> <9170C06E-85E6-428A-A5E5-56AF9379AD41@h3q.com> <2F0B8521-F568-4C68-B59C-1173203CE4E3@berlin.ccc.de> <40336AA2-17B7-433B-BCFA-30B172365781@h3q.com> <20100204194228.GA4555@dcvr.yhbt.net> <20100204201455.GA11834@dcvr.yhbt.net> Message-ID: <20100204212534.GA2551@dcvr.yhbt.net> John-Paul Bader wrote: > Sorry one more: > > Is this something you will address sooner or later or is this a "ruby > on bsd" bug? This bug actually affects anything that writes to sockets/pipes on BSD, not just Unicorn. So the patch should be backported to 1.8.7 upstream. -- Eric Wong From normalperson at yhbt.net Thu Feb 4 16:27:10 2010 From: normalperson at yhbt.net (Eric Wong) Date: Thu, 4 Feb 2010 13:27:10 -0800 Subject: "upstream timed out" after upgrades In-Reply-To: References: <5D2B92C5-8D0A-4810-B86B-06F670C6EFDB@h3q.com> <9D7E3DD2-4CE3-45FA-8383-34E33BCDA5C4@h3q.com> <20100204101149.GA14864@dcvr.yhbt.net> <9170C06E-85E6-428A-A5E5-56AF9379AD41@h3q.com> <2F0B8521-F568-4C68-B59C-1173203CE4E3@berlin.ccc.de> <40336AA2-17B7-433B-BCFA-30B172365781@h3q.com> <20100204194228.GA4555@dcvr.yhbt.net> <20100204201455.GA11834@dcvr.yhbt.net> Message-ID: <20100204212710.GB2551@dcvr.yhbt.net> John-Paul Bader wrote: > But if there is currently no other way to fix this issue I will of > course. I wonder if this issue always appears on ruby1.9. I will check > that out too. The original problem doesn't affect 1.9 at all, 1.9 doesn't mix stdio userspace wrapers with low-level unistd system calls. -- Eric Wong From normalperson at yhbt.net Thu Feb 4 16:52:01 2010 From: normalperson at yhbt.net (Eric Wong) Date: Thu, 4 Feb 2010 13:52:01 -0800 Subject: "upstream timed out" after upgrades In-Reply-To: References: <5D2B92C5-8D0A-4810-B86B-06F670C6EFDB@h3q.com> <9D7E3DD2-4CE3-45FA-8383-34E33BCDA5C4@h3q.com> <20100204101149.GA14864@dcvr.yhbt.net> <9170C06E-85E6-428A-A5E5-56AF9379AD41@h3q.com> <2F0B8521-F568-4C68-B59C-1173203CE4E3@berlin.ccc.de> <40336AA2-17B7-433B-BCFA-30B172365781@h3q.com> <20100204194228.GA4555@dcvr.yhbt.net> <20100204201455.GA11834@dcvr.yhbt.net> Message-ID: <20100204215201.GC2551@dcvr.yhbt.net> John-Paul Bader wrote: > Hmm, > > my C skills are really weak but this patch suppresses any IO errors > right? At least on BSD? Can you explain what exactly it is doing? Just > want to understand entirely. >From the beginning (a bit long, feel free to ask me for more clarification, too much of this is second nature to me by now and I may glance over important details...): There are two standard ways of doing IO in C: stdio.h (fwrite(3)/ fread(3)/fseek(2) ...) and the lower-level Unix system calls found in unistd.h (write(2)/read(2)/lseek(2)...) stdio.h functions are wrappers that do buffering in userspace and wrap the underlying unistd.h syscalls. They should not be used interchangeably on the same file descriptors. Unfortunately, Ruby 1.8 makes this mistake and uses them interchangeably in some places: bad. So when working with regular files, file offsets maintained in userspace via stdio did not get properly synchronized to the underlying kernel-level file offsets. That's why the fseeko(lseek()) was added to fix an issue exposed by Unicorn. lseek() was used to read the offset from the kernel, and then fseeko() is then used to synchronize the userspace offset to that of the kernel. All of this works well for seekable regular files. Now, sockets and pipes aren't seekable, so you'll get an error from the kernel if you try to seek on them. Errors from system calls are stored in "errno", a global variable that stores the error of the last system call executed. So since attempting to seek on an unseekable file sets errno, it clobbers the previous clean (or the "safe" value of EAGAIN[1]) errno. Eventually, this caused rb_sys_fail() function to be called, which raises a Ruby exception matching the current value of errno. [1] - EAGAIN (and EWOULDBLOCK on some systems) basically means "try calling this same function again, later". It gets returned when kernel buffers (not the userspace ones) are full if attempting to write, or empty if attempting to read. Since Ruby 1.8 relies on non-blocking I/O for sockets/pipes, the "blocking" write methods are coded to (eventually) retry on EAGAIN. > I thought your diff was the ruby diff of r26253 and didn't realize it > was yours ;) Actually, it's not mine, I just submitted the ticket that fixed one bug and introduced the one you hit :) -- Eric Wong From hukl at h3q.com Thu Feb 4 16:56:57 2010 From: hukl at h3q.com (John-Paul Bader) Date: Thu, 4 Feb 2010 22:56:57 +0100 Subject: "upstream timed out" after upgrades In-Reply-To: <20100204212534.GA2551@dcvr.yhbt.net> References: <9D7E3DD2-4CE3-45FA-8383-34E33BCDA5C4@h3q.com> <20100204101149.GA14864@dcvr.yhbt.net> <9170C06E-85E6-428A-A5E5-56AF9379AD41@h3q.com> <2F0B8521-F568-4C68-B59C-1173203CE4E3@berlin.ccc.de> <40336AA2-17B7-433B-BCFA-30B172365781@h3q.com> <20100204194228.GA4555@dcvr.yhbt.net> <20100204201455.GA11834@dcvr.yhbt.net> <20100204212534.GA2551@dcvr.yhbt.net> Message-ID: <4DF150E6-2898-4369-B25D-7B24764C49A6@h3q.com> True, and there are already a couple issues filed concerning this. Kind regards, John On 04.02.2010, at 22:25, Eric Wong wrote: > John-Paul Bader wrote: >> Sorry one more: >> >> Is this something you will address sooner or later or is this a "ruby >> on bsd" bug? > > This bug actually affects anything that writes to sockets/pipes on BSD, > not just Unicorn. So the patch should be backported to 1.8.7 upstream. > > -- > Eric Wong > _______________________________________________ > Unicorn mailing list - mongrel-unicorn at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-unicorn > Do not quote signatures (like this one) or top post when replying > From arojas at oogalabs.com Thu Feb 4 23:24:11 2010 From: arojas at oogalabs.com (Andres Rojas) Date: Thu, 4 Feb 2010 20:24:11 -0800 Subject: Unicorn Tuning Message-ID: Hi all, we've recently migrated from a mongrel setup to a Unicorn setup on most of our projects and we're trying to figure out how best to get stats about queued requests so we can tune accordingly. Our old setup: Hardware load balancer -----> Virtual Machine -----> Nginx -----> HAProxy -----> Mongrel New setup: Hardware load balancer -----> Virtual Machine -----> Nginx -----> Unicorn! The nice thing about HAProxy is that it gives you an easy way of seeing how many requests are queued up, which helps us determine how many slices we need, etc. With the loss of HAProxy in our Unicorn setup, I'm curious as how best to determine this. I've looked around in the mailing list and haven't come across much. Any help would be much appreciated. Thanks so much for an awesome piece of software! -a From normalperson at yhbt.net Fri Feb 5 05:52:56 2010 From: normalperson at yhbt.net (Eric Wong) Date: Fri, 5 Feb 2010 02:52:56 -0800 Subject: Unicorn Tuning In-Reply-To: References: Message-ID: <20100205105256.GB16881@dcvr.yhbt.net> Andres Rojas wrote: > Hi all, we've recently migrated from a mongrel setup to a Unicorn > setup on most of our projects and we're trying to figure out how best > to get stats about queued requests so we can tune accordingly. > > Our old setup: > Hardware load balancer -----> Virtual Machine -----> Nginx -----> > HAProxy -----> Mongrel > > > New setup: > Hardware load balancer -----> Virtual Machine -----> Nginx -----> Unicorn! > > > The nice thing about HAProxy is that it gives you an easy way of > seeing how many requests are queued up, which helps us determine how > many slices we need, etc. With the loss of HAProxy in our Unicorn > setup, I'm curious as how best to determine this. I've looked around > in the mailing list and haven't come across much. Any help would be > much appreciated. Hi Andres, You don't *have* to take HAproxy out if you really want to see the queue when using Unicorn :) But yes, the extra data copies with HAproxy will hurt performance slightly and it's more to manage. The obvious way would be send occasional monitoring requests to a "hello world" endpoint in your app, and then compare Unicorn response times (via the X-Runtime header in the application or your application log) with the actual time seen by the client (from the same LAN): time curl -iI http://example.com/_test | grep ^X-Runtime: This lets you notice bottlenecks in the entire stack, not just the nginx <-> unicorn path. Most folks I know do this (and monitor overall server load). Another possible way (untested with real traffic) to get rough data for the nginx <-> unicorn path is to have two listeners in Unicorn. One with a large backlog and the other with a small backlog: ------------ unicorn config ------------ listen "/tmp/.primary", :backlog => 5 listen "/tmp/.backup", :backlog => 1024 Then watching the nginx error log for errors going to the primary socket. The backup socket will be used whenever errors happen on the primary socket due to listen queue being full. ------------ nginx config ------------ error_log /tmp/nginx.error.log info; upstream app_server { server unix:/tmp/.primary fail_timeout=0; server unix:/tmp/.backup fail_timeout=0 backup; } If you see lots of errors going to .primary, then you can try increasing the backlog for that to something you're more comfortable with. -- Eric Wong From warren.konkel at gmail.com Sat Feb 6 07:33:13 2010 From: warren.konkel at gmail.com (Warren Konkel) Date: Sat, 6 Feb 2010 09:33:13 -0300 Subject: Confused classes Message-ID: I switched from mod_passenger to unicorn on a fairly high traffic site and ran into a strange problem that forced me to move back to mod_passenger... it seems as if classes would sometimes get mixed up with each other. If I had two Rails models: class Foo < ActiveRecord::Base; end class Bar < ActiveRecord::Base; end Normally Foo.inspect and Bar.inspect would return: Foo(field1: integer, field2: integer) Bar(field3: integer, field4: integer) When things were "broken" within a process, sometimes I would see: Foo(field3: integer, field4: integer) <--- note field3/field4 actually belong to Bar, not Foo And because of that, wacky errors would appear in my logs like: Foo.find_by_field1(12345) --> not a method Foo.create(:field1 => 12345) --> column not found I also noticed the problem with field serializing in ActiveRecord... given: class Boz < ActiveRecord::Base serialize :some_data end When processes were working correctly, Boz.find(1).some_data would return an actual object (like a Hash). When things were broken, the raw serialized string from the database would be returned... almost as if the Boz class "forgot" that it's supposed to deserialize "some_data". Could it be that class attributes are somehow being co-mingled when unicorn is starting up under high concurrency? Perhaps a mutex is missing somewhere? From ibc at aliax.net Sat Feb 6 08:06:04 2010 From: ibc at aliax.net (=?iso-8859-1?q?I=F1aki_Baz_Castillo?=) Date: Sat, 6 Feb 2010 14:06:04 +0100 Subject: Confused classes In-Reply-To: References: Message-ID: <201002061406.04172.ibc@aliax.net> El S?bado, 6 de Febrero de 2010, Warren Konkel escribi?: > I switched from mod_passenger to unicorn on a fairly high traffic site > and ran into a strange problem that forced me to move back to > mod_passenger... it seems as if classes would sometimes get mixed up > with each other. If I had two Rails models: > > class Foo < ActiveRecord::Base; end > class Bar < ActiveRecord::Base; end > > Normally Foo.inspect and Bar.inspect would return: > > Foo(field1: integer, field2: integer) > Bar(field3: integer, field4: integer) > > When things were "broken" within a process, sometimes I would see: > > Foo(field3: integer, field4: integer) <--- note field3/field4 > actually belong to Bar, not Foo > > And because of that, wacky errors would appear in my logs like: > > Foo.find_by_field1(12345) --> not a method > Foo.create(:field1 => 12345) --> column not found > > I also noticed the problem with field serializing in ActiveRecord... given: > > class Boz < ActiveRecord::Base > serialize :some_data > end > > When processes were working correctly, Boz.find(1).some_data would > return an actual object (like a Hash). When things were broken, the > raw serialized string from the database would be returned... almost as > if the Boz class "forgot" that it's supposed to deserialize > "some_data". > > Could it be that class attributes are somehow being co-mingled when > unicorn is starting up under high concurrency? Perhaps a mutex is > missing somewhere? IMHO all your Unicorn workers are sharing the same DB connection (the same ActiveRecord instances) so the problem arises. Take a look to the configuration here: http://unicorn.bogomips.org/examples/unicorn.conf.rb You can see there how the ActiveRecord is disconnected at the beggining and started for each worker later. -- I?aki Baz Castillo From normalperson at yhbt.net Sat Feb 6 21:01:19 2010 From: normalperson at yhbt.net (Eric Wong) Date: Sat, 6 Feb 2010 18:01:19 -0800 Subject: Confused classes In-Reply-To: <201002061406.04172.ibc@aliax.net> References: <201002061406.04172.ibc@aliax.net> Message-ID: <20100207020118.GA14392@dcvr.yhbt.net> I?aki Baz Castillo wrote: > El S?bado, 6 de Febrero de 2010, Warren Konkel escribi?: > > Could it be that class attributes are somehow being co-mingled when > > unicorn is starting up under high concurrency? Perhaps a mutex is > > missing somewhere? > > IMHO all your Unicorn workers are sharing the same DB connection (the same > ActiveRecord instances) so the problem arises. > > Take a look to the configuration here: > http://unicorn.bogomips.org/examples/unicorn.conf.rb > You can see there how the ActiveRecord is disconnected at the beggining and > started for each worker later. Yes, you have to reconnect any connected TCP sockets since they have no defined atomicity semantics when they're shared across processes/threads. Ruby Mutexes aren't useful at all here, they're only useful with threads in the same process. If you need to protect TCP client sockets from multiple processes, you'll need SysV/POSIX semaphores or file locks (flock/fcntl), but you're really better off using multiple TCP client sockets in the first place. -- Eric Wong From normalperson at yhbt.net Sat Feb 13 05:34:09 2010 From: normalperson at yhbt.net (Eric Wong) Date: Sat, 13 Feb 2010 10:34:09 +0000 Subject: [ANN] unicorn 0.96.1 - leak fix for Rainbows!/Zbatery Message-ID: <20100213103409.GA7833@dcvr.yhbt.net> First off, this memory leak doesn't affect Unicorn itself at all (but it doesn't hurt, either). Unicorn itself always allocates the HttpParser once and always reuses it in every sequential request. This leak only affects applications that repeatedly allocate a new HTTP parser. Thus this bug affects _all_ deployments of Rainbows! and Zbatery. These servers allocate a new parser for every client connection to serve clients concurrently, but due to a bug in Unicorn, never allows the Ruby GC to properly free the memory allocated. Here's what happened: I misread the Data_Make_Struct()/Data_Wrap_Struct() documentation and ended up passing NULL as the "free" argument instead of -1, causing the memory to never be freed. From README.EXT in the MRI source which I misread: > The free argument is the function to free the pointer > allocation. If this is -1, the pointer will be just freed. > The functions mark and free will be called from garbage > collector. Yes, I suck at reading and can't write code properly as a result. * http://unicorn.bogomips.org/ * mongrel-unicorn at rubyforge.org * git://git.bogomips.org/unicorn.git -- Eric Wong From noreply at vk.com Sun Feb 14 02:18:03 2010 From: noreply at vk.com (VK) Date: Sun, 14 Feb 2010 10:18:03 +0300 Subject: Darya Serdobintseva telah menambah awak sebagai kawan di tapak web VK.com Message-ID: Salam mu alaikum, Darya Serdobintseva telah menambah awak sebagai kawan di tapak web VK.com Awak boleh log in dan lihat laman kawan awak menggunakan email awak dan secara automatik membuat kata laluan: O8Sb2Qkl VK.com adalah laman web yang membantu dozenan jutaan orang mencari kawan lama mereka, berkongsi gambar dan acara dan selalu berhubungan. Untuk log in, sila ikuti link ini: http://vk.com/login.php?regemail=mongrel-unicorn at rubyforge.org#O8Sb2Qkl Awak boleh mengganti kata laluan awak dalam Tetapan. Perhatian: Jika awak mengabaikan jemputan ini, pendaftaran awak tidak akan diaktifkan. Semoga berjaya! From alexbarlowis at me.com Sun Feb 14 14:01:07 2010 From: alexbarlowis at me.com (Alex Barlow) Date: Sun, 14 Feb 2010 19:01:07 +0000 Subject: Nginx Sock And Rails Envinroment Error Message-ID: <0E8F6F3C-0406-4BC8-BA7A-539ADB500374@me.com> Hi There, Im running an amazon instance with nginx proxying to a unicorn sock. For some reason, even though i specify the production environment, when being visited by nginx, the site shows errors in development form. Interestingly, when running on a port rather than a sock, if i visit that port, the errors are rendered as normal with a 500 page, the same port, throught nginx, shows errors like you do in development. The app is rails latest (not 3), i run it with unicorn_rails -E production -c /root/pbr/current/config/unicorn.rb -D and unicorn.rb looks like.. worker_processes (20) preload_app(true) Im thinking it could be a permissions problem, the rails directory is in under root, nginx runs as user nginx, but i have given chown permission the the directory? Cheers, Alex Please CC alexbarlowis at me.com From normalperson at yhbt.net Mon Feb 15 02:30:43 2010 From: normalperson at yhbt.net (Eric Wong) Date: Sun, 14 Feb 2010 23:30:43 -0800 Subject: Nginx Sock And Rails Envinroment Error In-Reply-To: <0E8F6F3C-0406-4BC8-BA7A-539ADB500374@me.com> References: <0E8F6F3C-0406-4BC8-BA7A-539ADB500374@me.com> Message-ID: <20100215073043.GA22519@dcvr.yhbt.net> Alex Barlow wrote: > Hi There, > > Im running an amazon instance with nginx proxying to a unicorn sock. > > For some reason, even though i specify the production environment, > when being visited by nginx, the site shows errors in development > form. > > Interestingly, when running on a port rather than a sock, if i visit > that port, the errors are rendered as normal with a 500 page, the same > port, throught nginx, shows errors like you do in development. Hi Alex, Sorry, I'm having a little trouble following you, so you're saying: client <- TCP -> Unicorn => quiet errors (good) client <- TCP -> nginx <- TCP -> Unicorn => verbose errors (bad) client <- TCP -> nginx <- Unix socket-> Unicorn => verbose errors (bad) Are you sure you have nginx configured correctly and pointing to the right instance of your app? Mind sharing your nginx config file? > The app is rails latest (not 3), i run it with unicorn_rails -E > production -c /root/pbr/current/config/unicorn.rb -D > > and unicorn.rb looks like.. > > worker_processes (20) > preload_app(true) > > Im thinking it could be a permissions problem, the rails directory is > in under root, nginx runs as user nginx, but i have given chown > permission the the directory? nginx error logs should tell you if you have permissions problems. I usually specify domain sockets as a dot file in /tmp since I know the directory is world read/writeable on a properly configured system and path resolution is slightly faster :) -- Eric Wong From alexbarlowis at me.com Mon Feb 15 05:38:46 2010 From: alexbarlowis at me.com (Alex Barlow) Date: Mon, 15 Feb 2010 10:38:46 +0000 Subject: Nginx Sock And Rails Envinroment Error In-Reply-To: <20100215073043.GA22519@dcvr.yhbt.net> References: <0E8F6F3C-0406-4BC8-BA7A-539ADB500374@me.com> <20100215073043.GA22519@dcvr.yhbt.net> Message-ID: Hi It goes client <- TCP -> Unicorn => quiet errors (good) client <- TCP -> nginx <- TCP -> Unicorn => quiet errors (good) client <- TCP -> nginx <- Unix socket-> Unicorn => verbose errors (bad) Strange i know! Ill try the socket in /tmp/ see what that does. The Nginx error logs show nothing error wise really. My Nginx config is... user nginx; worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; gzip on; upstream unicorn_sock { server unix:/root/pbr/unicorn.sock; } server { listen 80; server_name localhost; proxy_set_header Host $host; location / { proxy_pass http://unicorn_sock; } } } This is currently throwing out verbose errors, in production (must be, its using asset host and the production database) Put the sock in /tmp, no difference On 15 Feb 2010, at 07:30, Eric Wong wrote: > Alex Barlow wrote: >> Hi There, >> >> Im running an amazon instance with nginx proxying to a unicorn sock. >> >> For some reason, even though i specify the production environment, >> when being visited by nginx, the site shows errors in development >> form. >> >> Interestingly, when running on a port rather than a sock, if i visit >> that port, the errors are rendered as normal with a 500 page, the same >> port, throught nginx, shows errors like you do in development. > > Hi Alex, > > Sorry, I'm having a little trouble following you, so you're saying: > > client <- TCP -> Unicorn => quiet errors (good) > client <- TCP -> nginx <- TCP -> Unicorn => verbose errors (bad) > client <- TCP -> nginx <- Unix socket-> Unicorn => verbose errors (bad) > > Are you sure you have nginx configured correctly and pointing to the > right instance of your app? Mind sharing your nginx config file? > >> The app is rails latest (not 3), i run it with unicorn_rails -E >> production -c /root/pbr/current/config/unicorn.rb -D >> >> and unicorn.rb looks like.. >> >> worker_processes (20) >> preload_app(true) >> >> Im thinking it could be a permissions problem, the rails directory is >> in under root, nginx runs as user nginx, but i have given chown >> permission the the directory? > > nginx error logs should tell you if you have permissions problems. > > I usually specify domain sockets as a dot file in /tmp since I know > the directory is world read/writeable on a properly configured system > and path resolution is slightly faster :) > > -- > Eric Wong From invite at eyari.com Mon Feb 15 09:45:40 2010 From: invite at eyari.com (eYari) Date: Mon, 15 Feb 2010 14:45:40 +0000 Subject: Sonia added you as a friend on eYari Message-ID: <000e0cd70ecac99ad1047fa4ab39@google.com> Hi, You are receiving this email because Sonia wants to tell you about this website which will analyze your horoscope and answer your Astrology questions free. Please click on the link below or copy and paste the URL into your browser: http://www.eyari.com/signup/?emailaddress=mongrel-unicorn at rubyforge.org&cid=7 To unsubscribe, click this link: http://www.eyari.com/unsubscribe/?emailaddress=mongrel-unicorn at rubyforge.org&cid=7 From normalperson at yhbt.net Mon Feb 15 11:19:18 2010 From: normalperson at yhbt.net (Eric Wong) Date: Mon, 15 Feb 2010 16:19:18 +0000 Subject: Nginx Sock And Rails Envinroment Error In-Reply-To: References: <0E8F6F3C-0406-4BC8-BA7A-539ADB500374@me.com> <20100215073043.GA22519@dcvr.yhbt.net> Message-ID: <20100215161917.GC4053@dcvr.yhbt.net> Alex Barlow wrote: > Hi > > It goes > > client <- TCP -> Unicorn => quiet errors (good) > client <- TCP -> nginx <- TCP -> Unicorn => quiet errors (good) > client <- TCP -> nginx <- Unix socket-> Unicorn => verbose errors (bad) > > Strange i know! Hi Alex, My gut feeling is that somehow nginx is hitting a different instance of your app when using the Unix socket. Other than that, I'm confused. More info/questions below. > Ill try the socket in /tmp/ see what that does. > > The Nginx error logs show nothing error wise really. My Nginx config is... > > user nginx; > worker_processes 1; > > events { > worker_connections 1024; > } > > http { > include mime.types; > default_type application/octet-stream; > > sendfile on; > keepalive_timeout 65; > gzip on; > > upstream unicorn_sock { > server unix:/root/pbr/unicorn.sock; > } > > server { > listen 80; > server_name localhost; > proxy_set_header Host $host; > > location / { > proxy_pass http://unicorn_sock; > } > } > } Nothing strange there, what's the verbosity of the nginx error_log? Also, anything enlightening in the Rails production.log or Unicorn stderr? Which OS are you running? Maybe there's a platform-specific bug somewhere, too... > This is currently throwing out verbose errors, in production (must be, > its using asset host and the production database) > > Put the sock in /tmp, no difference Is there another Unicorn instance on the same box that it might be somehow hitting? What happens when you try have Unicorn listening on both TCP and a Unix socket? Just put both "listen" directives in your config file and point nginx to the Unix socket. Then try hitting the Unicorn TCP port directly, and then also the Unix socket via nginx. You can also try hitting the Unix socket directly by crafting your own HTTP request using socat from th shell: req='GET / HTTP/1.1\r\nHost: example.com\r\n\r\n' printf "$req" | socat - UNIX:/root/pbr/unicorn.sock P.S.: I might not have a chance to respond again for the next day or so due to personal matters. Maybe somebody else on this list can help.... -- Eric Wong From alexbarlowis at me.com Mon Feb 15 17:14:31 2010 From: alexbarlowis at me.com (Alex Barlow) Date: Mon, 15 Feb 2010 22:14:31 +0000 Subject: Nginx Sock And Rails Envinroment Error In-Reply-To: <20100215161917.GC4053@dcvr.yhbt.net> References: <0E8F6F3C-0406-4BC8-BA7A-539ADB500374@me.com> <20100215073043.GA22519@dcvr.yhbt.net> <20100215161917.GC4053@dcvr.yhbt.net> Message-ID: <59201B66-973C-4810-BFFA-80E4A0B0610F@me.com> Fixed it! Rails was considering all requests to be local. As the request was coming from the local ip (from nginx i assume) i put these headers in nginx proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect false Works fine now Alex On 15 Feb 2010, at 16:19, Eric Wong wrote: > Alex Barlow wrote: >> Hi >> >> It goes >> >> client <- TCP -> Unicorn => quiet errors (good) >> client <- TCP -> nginx <- TCP -> Unicorn => quiet errors (good) >> client <- TCP -> nginx <- Unix socket-> Unicorn => verbose errors (bad) >> >> Strange i know! > > Hi Alex, > > My gut feeling is that somehow nginx is hitting a different instance of > your app when using the Unix socket. Other than that, I'm confused. > More info/questions below. > >> Ill try the socket in /tmp/ see what that does. >> >> The Nginx error logs show nothing error wise really. My Nginx config is... >> >> user nginx; >> worker_processes 1; >> >> events { >> worker_connections 1024; >> } >> >> http { >> include mime.types; >> default_type application/octet-stream; >> >> sendfile on; >> keepalive_timeout 65; >> gzip on; >> >> upstream unicorn_sock { >> server unix:/root/pbr/unicorn.sock; >> } >> >> server { >> listen 80; >> server_name localhost; >> proxy_set_header Host $host; >> >> location / { >> proxy_pass http://unicorn_sock; >> } >> } >> } > > Nothing strange there, what's the verbosity of the nginx error_log? > > Also, anything enlightening in the Rails production.log or Unicorn > stderr? > > Which OS are you running? Maybe there's a platform-specific bug > somewhere, too... > >> This is currently throwing out verbose errors, in production (must be, >> its using asset host and the production database) >> >> Put the sock in /tmp, no difference > > Is there another Unicorn instance on the same box that it might be > somehow hitting? > > What happens when you try have Unicorn listening on both TCP and a Unix > socket? Just put both "listen" directives in your config file and point > nginx to the Unix socket. Then try hitting the Unicorn TCP port > directly, and then also the Unix socket via nginx. > > You can also try hitting the Unix socket directly by crafting your > own HTTP request using socat from th shell: > > req='GET / HTTP/1.1\r\nHost: example.com\r\n\r\n' > printf "$req" | socat - UNIX:/root/pbr/unicorn.sock > > P.S.: I might not have a chance to respond again for the next day > or so due to personal matters. Maybe somebody else on this > list can help.... > > -- > Eric Wong From normalperson at yhbt.net Wed Feb 17 18:35:19 2010 From: normalperson at yhbt.net (Eric Wong) Date: Wed, 17 Feb 2010 15:35:19 -0800 Subject: Nginx Sock And Rails Envinroment Error In-Reply-To: <59201B66-973C-4810-BFFA-80E4A0B0610F@me.com> References: <0E8F6F3C-0406-4BC8-BA7A-539ADB500374@me.com> <20100215073043.GA22519@dcvr.yhbt.net> <20100215161917.GC4053@dcvr.yhbt.net> <59201B66-973C-4810-BFFA-80E4A0B0610F@me.com> Message-ID: <20100217233519.GA30036@dcvr.yhbt.net> Alex Barlow wrote: > Fixed it! > > Rails was considering all requests to be local. As the request was > coming from the local ip (from nginx i assume) Awesome. Good to know, I've been setting these headers for so long that it's become second nature and I've forgotten about side effects with Rails error messages :x > i put these headers in nginx > > proxy_set_header X-Real-IP $remote_addr; You probably don't need X-Real-IP, actually, it's quite nginx-specific and X-Forwarded-For covers you. > proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; > > proxy_set_header Host $http_host; > > proxy_redirect false From alexbarlowis at me.com Thu Feb 18 05:26:32 2010 From: alexbarlowis at me.com (Alex Barlow) Date: Thu, 18 Feb 2010 10:26:32 +0000 Subject: Nginx Sock And Rails Envinroment Error In-Reply-To: <20100217233519.GA30036@dcvr.yhbt.net> References: <0E8F6F3C-0406-4BC8-BA7A-539ADB500374@me.com> <20100215073043.GA22519@dcvr.yhbt.net> <20100215161917.GC4053@dcvr.yhbt.net> <59201B66-973C-4810-BFFA-80E4A0B0610F@me.com> <20100217233519.GA30036@dcvr.yhbt.net> Message-ID: Cool, thanxs for your support and great software. I get about 40 requests per second on a 1.7 gb instance with the db on the same host. Thats awesome! Well, i think so.. Alex On 17 Feb 2010, at 23:35, Eric Wong wrote: > Alex Barlow wrote: >> Fixed it! >> >> Rails was considering all requests to be local. As the request was >> coming from the local ip (from nginx i assume) > > Awesome. > > Good to know, I've been setting these headers for so long that it's > become second nature and I've forgotten about side effects with Rails > error messages :x > >> i put these headers in nginx >> >> proxy_set_header X-Real-IP $remote_addr; > > You probably don't need X-Real-IP, actually, it's quite nginx-specific > and X-Forwarded-For covers you. > >> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; >> >> proxy_set_header Host $http_host; >> >> proxy_redirect false From johnwulff at gmail.com Thu Feb 18 13:01:26 2010 From: johnwulff at gmail.com (John Wulff) Date: Thu, 18 Feb 2010 10:01:26 -0800 Subject: Rails 3 "RAILS_ENV not defined by config/boot" error Message-ID: I'm running unicorn and unicorn-rails 0.96.1 and the latest Rails 3 beta gem. ?Firing up unicorn_rails spews "RAILS_ENV not defined by config/boot". ?I know this is likely a result of RAILS_ROOT being deprecated?in Rails 3 but I can't seem to config my way around it. I'm sure other people must have run into this before. ?Is there a quick fix? Thanks From normalperson at yhbt.net Thu Feb 18 14:08:52 2010 From: normalperson at yhbt.net (Eric Wong) Date: Thu, 18 Feb 2010 11:08:52 -0800 Subject: Rails 3 "RAILS_ENV not defined by config/boot" error In-Reply-To: References: Message-ID: <20100218190852.GA10448@dcvr.yhbt.net> John Wulff wrote: > I'm running unicorn and unicorn-rails 0.96.1 and the latest Rails 3 > beta gem. ?Firing up unicorn_rails spews "RAILS_ENV not defined by > config/boot". ?I know this is likely a result of RAILS_ROOT being > deprecated?in Rails 3 but I can't seem to config my way around it. > I'm sure other people must have run into this before. ?Is there a > quick fix? Hi John, I haven't had a chance to look at Rails 3 yet, but you can probably try just using a plain config.ru with "unicorn" (not "unicorn_rails") ------------------- config.ru ------------------ ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] require "config/environment" use Rails::Rack::Static run ActionController::Dispatcher.new ------------------------------------------------ Let us know how it goes, thanks! -- Eric Wong From hukl at h3q.com Thu Feb 18 14:13:43 2010 From: hukl at h3q.com (John-Paul Bader) Date: Thu, 18 Feb 2010 20:13:43 +0100 Subject: Rails 3 "RAILS_ENV not defined by config/boot" error In-Reply-To: <20100218190852.GA10448@dcvr.yhbt.net> References: <20100218190852.GA10448@dcvr.yhbt.net> Message-ID: Hey guys, actually I was running my new blog on rails3 and unicorn. I wanted to post about it here but didn't have the time yet. Indeed you just need unicorn - not unicorn rails. It seems to run all really well - I just need to modify my rc script a bit. Kind regards, John On 18.02.2010, at 20:08, Eric Wong wrote: > John Wulff wrote: >> I'm running unicorn and unicorn-rails 0.96.1 and the latest Rails 3 >> beta gem. Firing up unicorn_rails spews "RAILS_ENV not defined by >> config/boot". I know this is likely a result of RAILS_ROOT being >> deprecated in Rails 3 but I can't seem to config my way around it. >> I'm sure other people must have run into this before. Is there a >> quick fix? > > Hi John, > > I haven't had a chance to look at Rails 3 yet, but you can probably try > just using a plain config.ru with "unicorn" (not "unicorn_rails") > > ------------------- config.ru ------------------ > ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] > require "config/environment" > use Rails::Rack::Static > run ActionController::Dispatcher.new > ------------------------------------------------ > > Let us know how it goes, thanks! > > -- > Eric Wong > _______________________________________________ > Unicorn mailing list - mongrel-unicorn at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-unicorn > Do not quote signatures (like this one) or top post when replying > From johnw at orcasnet.com Thu Feb 18 14:26:19 2010 From: johnw at orcasnet.com (John Wulff) Date: Thu, 18 Feb 2010 11:26:19 -0800 Subject: Rails 3 "RAILS_ENV not defined by config/boot" error In-Reply-To: References: <20100218190852.GA10448@dcvr.yhbt.net> Message-ID: Fantastic! Thanks On Thu, Feb 18, 2010 at 11:13 AM, John-Paul Bader wrote: > Hey guys, > > actually I was running my new blog on rails3 and unicorn. I wanted to post about it here but didn't have the time yet. Indeed you just need unicorn - not unicorn rails. It seems to run all really well - I just need to modify my rc script a bit. > > Kind regards, John > > On 18.02.2010, at 20:08, Eric Wong wrote: > >> John Wulff wrote: >>> I'm running unicorn and unicorn-rails 0.96.1 and the latest Rails 3 >>> beta gem. ?Firing up unicorn_rails spews "RAILS_ENV not defined by >>> config/boot". ?I know this is likely a result of RAILS_ROOT being >>> deprecated in Rails 3 but I can't seem to config my way around it. >>> I'm sure other people must have run into this before. ?Is there a >>> quick fix? >> >> Hi John, >> >> I haven't had a chance to look at Rails 3 yet, but you can probably try >> just using a plain config.ru with "unicorn" (not "unicorn_rails") >> >> ------------------- config.ru ------------------ >> ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] >> require "config/environment" >> use Rails::Rack::Static >> run ActionController::Dispatcher.new >> ------------------------------------------------ >> >> Let us know how it goes, thanks! >> >> -- >> Eric Wong >> _______________________________________________ >> Unicorn mailing list - mongrel-unicorn at rubyforge.org >> http://rubyforge.org/mailman/listinfo/mongrel-unicorn >> Do not quote signatures (like this one) or top post when replying >> > > _______________________________________________ > Unicorn mailing list - mongrel-unicorn at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-unicorn > Do not quote signatures (like this one) or top post when replying > From steve at steveklabnik.com Thu Feb 18 15:41:20 2010 From: steve at steveklabnik.com (Steve Klabnik) Date: Thu, 18 Feb 2010 20:41:20 +0000 Subject: Capistrano and Unicorn Message-ID: Anyone have any tips for using Capistrano with unicorn? I'm following what GitHub did (http://github.com/blog/517-unicorn) , and for some reason, my old master isn't dying correctly. If I `pkill -9 unicorn_rails && unicorn_rails` the new code shows up. I'm thinking the problem may be with how capistrano uses the 'current' directory as a symlink. That config's before_fork seems to make sense to me; I might just be doing something stupid. Here's my config, for reference: # Use at least one worker per core if you're on a dedicated server, # more will usually help for _short_ waits on databases/caches. worker_processes 16 working_directory "/home/git/site/current" # available in 0.94.0+ # listen on both a Unix domain socket and a TCP port, # we use a shorter backlog for quicker failover when busy listen "/tmp/.sock", :backlog => 64 listen 8080, :tcp_nopush => true timeout 600 pid "/var/run/unicorn.pid" # some applications/frameworks log to stderr or stdout, so prevent # them from going to /dev/null when daemonized here: stderr_path "/var/log/unicorn.stderr.log" stdout_path "/var/log/unicorn.stdout.log" # combine REE with "preload_app true" for memory savings # http://rubyenterpriseedition.com/faq.html#adapt_apps_for_cow preload_app true GC.respond_to?(:copy_on_write_friendly=) and GC.copy_on_write_friendly = 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! old_pid = RAILS_ROOT + '/tmp/pids/unicorn.pid.oldbin' if File.exists?(old_pid) && server.pid != old_pid begin Process.kill("QUIT", File.read(old_pid).to_i) rescue Errno::ENOENT, Errno::ESRCH # someone else did our job for us end end end after_fork do |server, worker| # the following is *required* for Rails + "preload_app true", defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection end I am using ree, so preload_app should be in effect. Thanks in advance. From normalperson at yhbt.net Thu Feb 18 18:36:32 2010 From: normalperson at yhbt.net (Eric Wong) Date: Thu, 18 Feb 2010 15:36:32 -0800 Subject: Rails 3 "RAILS_ENV not defined by config/boot" error In-Reply-To: <20100218190852.GA10448@dcvr.yhbt.net> References: <20100218190852.GA10448@dcvr.yhbt.net> Message-ID: <20100218233632.GA24894@dcvr.yhbt.net> Eric Wong wrote: > John Wulff wrote: > > I'm running unicorn and unicorn-rails 0.96.1 and the latest Rails 3 > > beta gem. ?Firing up unicorn_rails spews "RAILS_ENV not defined by > > config/boot". ?I know this is likely a result of RAILS_ROOT being > > deprecated?in Rails 3 but I can't seem to config my way around it. > > I'm sure other people must have run into this before. ?Is there a > > quick fix? > > Hi John, > > I haven't had a chance to look at Rails 3 yet, but you can probably try > just using a plain config.ru with "unicorn" (not "unicorn_rails") I've been planning on some large-ish changes in Unicorn 0.97.x to bin/{unicorn,unicorn_rails} to make maintenance easier and fix a few minor issues with the existing code. Would the following change be enough to work with Rails 3 out-of-the-box? diff --git a/bin/unicorn_rails b/bin/unicorn_rails index b1458fc..4441c34 100755 --- a/bin/unicorn_rails +++ b/bin/unicorn_rails @@ -128,8 +128,6 @@ app = lambda do || rescue LoadError => err abort "#$0 must be run inside RAILS_ROOT: #{err.inspect}" end - defined?(::RAILS_ROOT) or abort "RAILS_ROOT not defined by config/boot" - defined?(::RAILS_ENV) or abort "RAILS_ENV not defined by config/boot" defined?(::Rails::VERSION::STRING) or abort "Rails::VERSION::STRING not defined by config/boot" (I'll remember to test when I fix a few other things elsewhere) -- Eric Wong From mguterl at gmail.com Thu Feb 18 18:31:14 2010 From: mguterl at gmail.com (Michael Guterl) Date: Thu, 18 Feb 2010 18:31:14 -0500 Subject: Capistrano and Unicorn In-Reply-To: References: Message-ID: <944a03771002181531r206690edq43e9de0c15c11035@mail.gmail.com> On Thu, Feb 18, 2010 at 3:41 PM, Steve Klabnik wrote: > Anyone have any tips for using Capistrano with unicorn? > Here's the init script we're using to manage unicorn: http://gist.github.com/308216 some of it may be of use, I can't remember where we originally found it. We call `/etc/init.d/unicorn upgrade` in our deploy:restart task. > I'm following what GitHub did (http://github.com/blog/517-unicorn) , > and for some reason, my old master isn't dying correctly. If I `pkill > -9 unicorn_rails && unicorn_rails` the new code shows up. I'm thinking > the problem may be with how capistrano uses the 'current' directory as > a symlink. > Also be sure to check out http://unicorn.bogomips.org/SIGNALS.html it is very comprehensive. Best, Michael GUterl From superjoe at gmail.com Thu Feb 25 14:37:25 2010 From: superjoe at gmail.com (Joseph McDonald) Date: Thu, 25 Feb 2010 11:37:25 -0800 Subject: fork on client connection? Message-ID: <73096a161002251137h14caabc4hca0521bd570c8edc@mail.gmail.com> Would it be possible to configure unicorn to fork off your rack process when it gets a connection from a client as opposed to preforking the workers? While in development mode I have my app kill itself after serving a request, however at that point unicorn fires up a new one right away. If it could wait until it got a connection from a client, that would be *super awesome* for development mode. thanks, -joe From sunaku at gmail.com Thu Feb 25 15:50:48 2010 From: sunaku at gmail.com (Suraj Kurapati) Date: Thu, 25 Feb 2010 12:50:48 -0800 Subject: fork on client connection? In-Reply-To: <73096a161002251137h14caabc4hca0521bd570c8edc@mail.gmail.com> References: <73096a161002251137h14caabc4hca0521bd570c8edc@mail.gmail.com> Message-ID: On Thu, Feb 25, 2010 at 11:37 AM, Joseph McDonald wrote: > Would it be possible to configure unicorn to fork off your rack > process when it gets a connection from a client as opposed to > preforking ?the workers? +1 From normalperson at yhbt.net Thu Feb 25 17:43:55 2010 From: normalperson at yhbt.net (Eric Wong) Date: Thu, 25 Feb 2010 14:43:55 -0800 Subject: fork on client connection? In-Reply-To: <73096a161002251137h14caabc4hca0521bd570c8edc@mail.gmail.com> References: <73096a161002251137h14caabc4hca0521bd570c8edc@mail.gmail.com> Message-ID: <20100225224355.GA605@dcvr.yhbt.net> Joseph McDonald wrote: > Would it be possible to configure unicorn to fork off your rack > process when it gets a connection from a client as opposed to > preforking the workers? While in development mode I have my app kill > itself after serving a request, however at that point unicorn fires up > a new one right away. If it could wait until it got a connection from > a client, that would be *super awesome* for development mode. Hi Joseph, Instead of forking late, you could avoid building your app until a client has been accepted. Try this in your Unicorn config file: preload_app false # default after_fork do |server, worker| server.app = server.orig_app server.preload_app = true def server.process_client(client) build_app! Process.kill(:QUIT, $$) # exit after serving super end end -- Eric Wong From johnwulff at gmail.com Thu Feb 25 22:13:33 2010 From: johnwulff at gmail.com (John Wulff) Date: Thu, 25 Feb 2010 19:13:33 -0800 Subject: Launch Problem Message-ID: I'm experiencing this, can't seem to figure it out. Any help would be appreciated, thanks! $ unicorn_rails -c current/config/unicorn.rb -E production current/config/unicorn.rb:2:in `reload': uninitialized constant Unicorn::Configurator::YAML (NameError) from /usr/local/lib/ruby/gems/1.8/gems/unicorn-0.96.0/lib/unicorn/configurator.rb:42:in `initialize' from /usr/local/lib/ruby/gems/1.8/gems/unicorn-0.96.0/lib/unicorn.rb:167:in `new' from /usr/local/lib/ruby/gems/1.8/gems/unicorn-0.96.0/lib/unicorn.rb:167:in `initialize' from /usr/local/lib/ruby/gems/1.8/gems/unicorn-0.96.0/lib/unicorn.rb:28:in `new' from /usr/local/lib/ruby/gems/1.8/gems/unicorn-0.96.0/lib/unicorn.rb:28:in `run' from /usr/local/lib/ruby/gems/1.8/gems/unicorn-0.96.0/bin/unicorn_rails:207 from /usr/local/bin/unicorn_rails:19:in `load' from /usr/local/bin/unicorn_rails:19 From normalperson at yhbt.net Fri Feb 26 02:45:01 2010 From: normalperson at yhbt.net (Eric Wong) Date: Thu, 25 Feb 2010 23:45:01 -0800 Subject: Launch Problem In-Reply-To: References: Message-ID: <20100226074501.GA16506@dcvr.yhbt.net> John Wulff wrote: > I'm experiencing this, can't seem to figure it out. Any help would be > appreciated, thanks! > > $ unicorn_rails -c current/config/unicorn.rb -E production > current/config/unicorn.rb:2:in `reload': uninitialized constant > Unicorn::Configurator::YAML (NameError) Hi John, Unicorn itself doesn't use YAML anywhere, so you're probably just forgetting to load it somewhere in your config file: require 'yaml' Some servers (Mongrel, Thin) use YAML config files, so they would've already required 'yaml' for you. -- Eric Wong From johnwulff at gmail.com Fri Feb 26 02:52:10 2010 From: johnwulff at gmail.com (John Wulff) Date: Thu, 25 Feb 2010 23:52:10 -0800 Subject: Launch Problem In-Reply-To: <20100226074501.GA16506@dcvr.yhbt.net> References: <20100226074501.GA16506@dcvr.yhbt.net> Message-ID: <-3677663222340569032@unknownmsgid> Thanks for the gentle response Eric. I did indeed forget an include, so emberrasing. On Feb 25, 2010, at 11:45 PM, Eric Wong wrote: > John Wulff wrote: >> I'm experiencing this, can't seem to figure it out. Any help would >> be >> appreciated, thanks! >> >> $ unicorn_rails -c current/config/unicorn.rb -E production >> current/config/unicorn.rb:2:in `reload': uninitialized constant >> Unicorn::Configurator::YAML (NameError) > > Hi John, > > Unicorn itself doesn't use YAML anywhere, so you're probably just > forgetting to load it somewhere in your config file: > > require 'yaml' > > Some servers (Mongrel, Thin) use YAML config files, so they would've > already required 'yaml' for you. > > -- > Eric Wong From mirate at brug-it.nl Fri Feb 26 17:26:13 2010 From: mirate at brug-it.nl (Buy Levitra on www.55-00.cn) Date: Fri, 26 Feb 2010 23:26:13 +0100 Subject: precr itica l irrep ealab le Message-ID: <4B884969.5050302@bertvisscher.nl> coffl e selen ious canni ness promo tes deter rents zithe rist patin ae reent rant chemi strie s econo metri cs liber taria ns econo metri cs quant um monke ries cysts elect rocut e plugg er syren snail gappe d fibro sis glimm er vecto rizer pinet um sands torms begri me langu or inher ed reser ves equin es patel las booge yman unsat urate begri me leavi ngs unsat urate reaso ned aspar tic