Tag: server

Ruby on Rails + Webrick: ERROR NoMethodError: undefined method ‘split’ for nil:NilClass

Recently after updating Ruby on Rails, after runnig Webrick in a development mode, it started to crush with such an error:

 ERROR NoMethodError: undefined method `split' for nil:NilClass
    /home/path/gems/rack-1.4.3/lib/rack/handler/webrick.rb:68:in `block in service'
    /home/path/gems/rack-1.4.3/lib/rack/utils.rb:387:in `block in each'
    /home/path/gems/rack-1.4.3/lib/rack/utils.rb:386:in `each'
    /home/path/gems/rack-1.4.3/lib/rack/utils.rb:386:in `each'
    /home/path/gems/rack-1.4.3/lib/rack/handler/webrick.rb:62:in `service'
    /home/path/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
    /home/path/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
    /home/path/ruby-1.9.3-p194/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'

I don't know why it happens but I know how to fix it ;)
To do so, you need to find 68 line in a Webric server:

# Ofc change the path to your Webrick path
vim /home/path/gems/rack-1.4.3/lib/rack/handler/webrick.rb

Localize line 68 and change:

res[k] = vs.split("\n").join(", ")

to:

res[k] = vs.to_s.split("\n").join(", ")

It seams that the header value is somehow nil, that's why we cast it to empty string.

Munin: This RRD was created on another architecture – migrating between 32 and 64bit systems

When I was moving Senpuu.net to a new location, I've wanted to preserve my Munin stats (since my new server have almost identical configuration they will be very useful to me). Unfortunately moving RRD files between different architectures is not possible. To copy Munin data to a new server with a different architecture, we need to use rrdtool (dump and restore).

# Error example from /var/log/munin/munin-node.log
This RRD was created on another architecture

rrd dump and restore

Lets quote a man for rrdtool:

Dump:

Dump the contents of an RRD in plain ASCII. In connection with restore you can use this to move an RRD from one computer architecture to another.

Restore:

Restore an RRD in XML format to a binary RRD.

Now everything looks better. We can easily dump RRD files to XML, move them to the other server and then easily restore them to RRD format.

To dump all RRD files for given node, you need to get (as root) to RRD files dir (by default it should be somewhere near /var/lib/munin) and execute following code:

cd /var/lib/munin/senpuu
# Create a dir for RRD dumps
mkdir ./../rrd_dump
 for i in ./*.rrd;do rrdtool dump $i ./../rrd_dump/$i.xml;done

The above code will create XML dumps in appropriate directory. When this is finished, you need to download all the files and upload them to your new server. Then execute:

# Execute this on a new server
cd /var/lib/munin/rrd_dump
for i in ./*.xml; do rrdtool restore "$i" "../senpuu/${i%.xml}"; done

after this you might reset munin-node just to be sure that everything will work fine:

/etc/init.d/munin-node restart

Now you should have your old charts up and running.

Copyright © 2024 Closer to Code

Theme by Anders NorenUp ↑