Advertisement
Bienvenido a Squishdot Reportes Anuncios Debian Ciencia Linux
 principal
 nivel superior
 enviar artículo
 buscar
 administrar
 acerca de ...
 rdf
 rss
 main


Primer Reporte de Junio
Anuncios Posted by Víctor Martínez on Monday June 09, @03:38PM el 2008
from the dept.
Como ha mencionado Gunnar hemos estado trabajando en diagnosticar por que la aplicación en ROR se sigue muriendo.
Tenemos por ahi una aplicación corriendo en Ruby on Rails (ROR). En Debian Etch (stable), sin embargo para utilizarla de manera nativa nos encontramos con que usarla como fast cgi en Apache 1.3.x es por decirlo de una manera bonita, extremadamente dificil.

Asi que usamos un backport de mongrel... primer problema, mod_proxy que en apache 2.2.x ha mejorado enormidades, en apache 1.3.x funciona, pero con sus asegunes... entonces pense en hacer aptitude install apache2... sin embargo creo es mejor a que acabe el semestre antes de migrar mis cosas a apache2.

Por otro lado estuve haciendo strace del mongrel antes de que por sugerencia de mi compañero sysadmin se implementara mongrel_cluster + pound + apache_mod_proxy :D

Total que en su ultima corrida como mongrel_rails...

Tan solo nos quedamos con este error.

sigprocmask(SIG_BLOCK, NULL, []) = 0
sigprocmask(SIG_BLOCK, NULL, []) = 0
sigprocmask(SIG_BLOCK, NULL, []) = 0
sigprocmask(SIG_BLOCK, NULL, []) = 0
sigprocmask(SIG_BLOCK, NULL, []) = 0
sigprocmask(SIG_BLOCK, NULL, []) = 0
sigprocmask(SIG_BLOCK, NULL, []) = 0
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
write(2, "/home/webapps/railapp"..., 94) = 94
write(2, "[BUG] ", 6) = 6
write(2, "Segmentation fault", 18) = 18
write(2, "\nruby 1.8.5 (2006-08-25) [i486-l"..., 39) = 39
rt_sigprocmask(SIG_UNBLOCK, [ABRT], NULL, 8) = 0
tgkill(16616, 16616, SIGABRT) = 0
--- SIGABRT (Aborted) @ 0 (0) ---
rt_sigprocmask(SIG_BLOCK, [ABRT], NULL, 8) = 0
rt_sigaction(SIGABRT, {SIG_DFL}, {0xb6e49060, [ABRT], SA_INTERRUPT}, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [ABRT], NULL, 8) = 0
tgkill(16616, 16616, SIGABRT) = 0
--- SIGABRT (Aborted) @ 0 (0) ---
Process 16616 detached

Y en los logs

mongrel.8202.log:/usr/lib/ruby/1.8/cgi/session.rb:166: [BUG] rb_gc_mark(): unkno
wn data type 0x25(0xbff08948) non object
mongrel.8204.log:/usr/lib/ruby/1.8/cgi/session.rb:166: [BUG] Segmentation fault
mongrel.log:/usr/lib/ruby/1.8/cgi/session.rb:166: [BUG] Segmentation fault
mongrel.log:/usr/lib/ruby/1.8/cgi/session.rb:166: [BUG] Segmentation fault
mongrel.log:127.0.0.1 - [Wed, 23 Apr 2008 07:24:27 GMT] "GET /centers/list HTTP/
1.1"/usr/lib/ruby/1.8/mongrel/debug.rb:180: [BUG] Segmentation fault
mongrel.log:/home/webapps/railapp/vendor/plugins/will_paginate/lib
/will_paginate/finder.rb:155: [BUG] rb_gc_mark(): unknown data type 0x0(0x8e3711
8) non object
mongrel.log:/usr/lib/ruby/1.8/mongrel/stats.rb:44: [BUG] Segmentation fault
mongrel.log:/usr/lib/ruby/1.8/mongrel/debug.rb:180: [BUG] Segmentation fault
mongrel.log:/usr/lib/ruby/1.8/cgi/session.rb:166: [BUG] Segmentation fault
mongrel.log:/usr/lib/ruby/1.8/cgi/session.rb:166: [BUG] Segmentation fault
mongrel.log:/home/webapps/railapp/vendor/rails/activerecord/lib/ac
tive_record/connection_adapters/postgresql_adapter.rb:87: [BUG] Segmentation fau
lt
mongrel.log:/usr/lib/ruby/1.8/cgi/session.rb:166: [BUG] Segmentation fault
mongrel.log:/usr/lib/ruby/1.8/cgi/session.rb:166: [BUG] Segmentation fault
mongrel.log:/usr/lib/ruby/1.8/cgi/session.rb:166: [BUG] Segmentation fault
mongrel.log:/usr/lib/ruby/1.8/cgi/session.rb:166: [BUG] Segmentation fault
mongrel.log:/usr/lib/ruby/1.8/cgi/session.rb:166: [BUG] Segmentation fault
mongrel.log:/usr/lib/ruby/1.8/cgi/session.rb:166: [BUG] Segmentation fault
...
mongrel.log:/usr/lib/ruby/1.8/cgi/session.rb:166: [BUG] Segmentation fault
mongrel.log:/usr/lib/ruby/1.8/cgi/session.rb:166: [BUG] Segmentation fault
mongrel.log:/usr/lib/ruby/1.8/cgi/session.rb:166: [BUG] Segmentation fault

Haciendo un par de busquedas en google (bueno más que un par) no econtre ningun ticket abierto en Debian, Ruby o Mongrel :/, asi que seguimos con una solución a la medida que cuando pesca que mongrel se muere lo reinicia...

Originalmente habia hecho uno muy rudimentario, pero que igual a alguien mas le podria servir, asi que pongo mi script de bash.

#!/bin/sh
# start mongrel if dies
#TEST=`ps xaf | grep mogrel_rails | grep -v grep | wc -l`
TEST=`ps xaf | grep "/usr/bin/ruby1.8" | grep -v grep | wc -l`
#echo $TEST
if [ $TEST == 0 ] ; then
# Hard coded
rm /home/webapps/railapp/log/mongrel.pid
echo "Mongrel ha muerto, borrando su pid"
/etc/init.d/mongrels start
echo "levantando"
fi

exit 0


Como nota interesante si mongrel se muere con segfault no borra su pid, por lo tanto no es posible iniciarlo sin borrar el pid primero, claro que mi script seria más eficiente si mejor leyera el pid, lo buscara contra los procesos y solo si no lo encuentra entonces si levantara a mongrel, pero como necesitabamos un quick hack ese día, asi se quedo, Gunnar mejoro el script y con mongrel_cluster, lanza cinco instancias de mongrel, con lo que aun cuando alguno de ellos haga segfault da bastante margen para que entre tambien su nuevo script mucho mas refinado, que esta revisando el estado del cluster cada minuto y que al encontrarse uno o mas fuera de linea hace un reload... el codigo a continuacion, tomado del blog de Gunnar.

#!/usr/bin/ruby

require 'yaml'

confdir = '/etc/mongrel-cluster/sites-enabled'

restart_cmd = '/etc/init.d/mongrel-cluster restart'

needs_restart = false

(Dir.open(confdir).entries - ['.', '..']).each do |site|

conf = YAML.load_file "#{confdir}/#{site}"

pid_location = [conf['cwd'], conf['pid_file']].join('/').gsub(/\.pid$/, '*.pid')

pid_files = Dir.glob(pid_location)

pid_files.each do |pidf|

pid = File.read(pidf)

begin

Process.getpgid(pid.to_i)

rescue Errno::ESRCH

warn "Process #{pid} (cluster #{site}) is dead!"

File.unlink pidf

needs_restart = true

end

end

end

system(restart_cmd) if needs_restart


Avances Twexter | Reporte  >

 

Related Links
  • Articles on Anuncios
  • Also by Víctor Martínez
  • Contact author
  • The Fine Print: The following comments are owned by whoever posted them.
    ( Reply )

    Powered by Zope  Squishdot Powered
      "Any system that depends on reliability is unreliable." -- Nogg's Postulate
    All trademarks and copyrights on this page are owned by their respective companies. Comments are owned by the Poster. The Rest ©1999 Butch Landingin.
    [ home | post article | search | admin ]