view · edit · sidebar · attach · print · history

20130613-setup-bbmb-sandoz-in-fastpower

<< | Index | >>


Summary

  • Re-compile ruby 1.8.6 + oniguruma and --enable-shared
  • Install ruby gems
    • resolve dependency of gems
  • Install mod_ruby
    • against ruby186
  • Fixed some Errors and Warning for default apache configuration

Commits

Index


Ruby-1.8.6

There is a already ruby186 in /usr/local/bin/ruby186/bin/ruby with oniguruma patch.

I re-compiled with --enable-shared option.
This option is needed for mod_ruby.

$ cd /usr/local/src/ruby-1.8.6-p369
$ make clean
$ ./configure --prefix=/usr/local/bin/ruby186/ --enable-shared
$ make
$ sudo make install

Environment variable

There is a error that related in auto_gem.

fastpower sandoz.bbmb.ch $ /usr/local/bin/ruby186/bin/gem    
/usr/local/bin/ruby186/bin/ruby: no such file to load -- auto_gem (LoadError)

We could avoid this error with RUBYOPT="".

$ RUBYOPT="" /usr/local/bin/ruby186/bin/gem -v
1.4.1

I loaded this Enviromnet variable into /etc/env.d like this.

$ sudo cat /etc/env.d/99ruby
RUBYOPT=""
$ sudo etc-update && source /etc/profile

link


Install gems for sandoz.bbmb.ch

Gemfile

source "https://rubygems.org"

gem 'ruby-json'
gem 'sbsm'
gem 'htmlgrid'
gem 'yus'
gem 'rclconf'
gem 'character-encodings', '0.3.0'
gem 'rmail'
gem 'hpricot'
gem 'ydim'
gem 'odba'
gem "smtp_tls"
gem "pg", "0.8.0"     #=> does not use dependency of dbd-pg. (Please specify before dbd-pg)
gem "dbd-pg", "0.3.9"
gem "dbi", "0.4.5"
gem "deprecated", "2.0.1"

I could not use bundler.
I installed by hand.

Fetching: bundler-1.3.5.gem (100%)
ERROR:  Error installing bundler:
        bundler requires Ruby version >= 1.8.7.

There is a Regexp with ruby-1.8.6 + oniguruma in bbmb/lib/bbmb/util/polling_manager.rb:48.
bbmb needs ruby-1.8.6 + oniguruma.

@@ptrn = /name=(?:(?:(?<quote>['"])(?:=\?.+?\?[QB]\?)?(?<file>.*?)(\?=)?(?<!\\)\k<quote>)|(?:(?<file>.+?)(?:;|$)))/i

\# in my local, I ignored this regexp ...

But,
with ruby-1.8.6 we could not already install pg any more.

fastpower sandoz.bbmb.ch #$ /usr/local/bin/ruby186/bin/gem install dbd-pg -v 0.3.9
Fetching: pg-0.15.1.gem (100%)
ERROR:  Error installing dbd-pg:
        pg requires Ruby version >= 1.8.7.

Then I installed very old pg 0.8.0 (maybe 3-5 yeas ago) before install dbd-pg.

fastpower sandaz.bbmb.ch $ /usr/local/bin/ruby186/bin/gem install pg -v 0.8.0
Fetching: pg-0.8.0.gem (100%)
Building native extensions.  This could take a while...
Successfully installed pg-0.8.0
1 gem installed
Installing ri documentation for pg-0.8.0...
Installing RDoc documentation for pg-0.8.0...

Run bbmbd

fastpower sandoz.bbmb.ch $ /usr/local/bin/ruby186/bin/ruby -rrubygems ./bin/bbmbd --config="etc/config.yml"
/usr/local/bin/ruby186/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in `gem_original_require': no such file to load -- bbmb/config (LoadError)
        from /usr/local/bin/ruby186/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in `require'
        from ./bin/bbmbd:9

Then I specified -I/path/to/bbmb/lib

fastpower sandoz.bbmb.ch $ /usr/local/bin/ruby186/bin/ruby -rrubygems -I/usr/local/share/src/bbmb/lib ./bin/bbmbd  --config="etc/config.yml"
/usr/local/bin/ruby186/lib/ruby/gems/1.8/gems/htmlgrid-1.0.6/lib/htmlgrid/grid.rb:28: warning: already initialized constant VERSION
could not find htmlgrid.so, falling back to pure-ruby class
/usr/local/bin/ruby186/lib/ruby/gems/1.8/gems/dbi-0.4.5/lib/dbi.rb:300:in `load_driver': Unable to load driver 'pg' (underlying error: wrong constant name pg) (DBI::InterfaceError)
        from /usr/local/bin/ruby186/lib/ruby/1.8/monitor.rb:242:in `synchronize'
        from /usr/local/bin/ruby186/lib/ruby/gems/1.8/gems/dbi-0.4.5/lib/dbi.rb:242:in `load_driver'
        from /usr/local/bin/ruby186/lib/ruby/gems/1.8/gems/dbi-0.4.5/lib/dbi.rb:160:in `_get_full_driver'
        from /usr/local/bin/ruby186/lib/ruby/gems/1.8/gems/dbi-0.4.5/lib/dbi.rb:145:in `connect'
        from /usr/local/bin/ruby186/lib/ruby/gems/1.8/gems/odba-1.1.0/lib/odba/connection_pool.rb:63:in `_connect'
        from /usr/local/bin/ruby186/lib/ruby/gems/1.8/gems/odba-1.1.0/lib/odba/connection_pool.rb:62:in `times'
        from /usr/local/bin/ruby186/lib/ruby/gems/1.8/gems/odba-1.1.0/lib/odba/connection_pool.rb:62:in `_connect'
        from /usr/local/bin/ruby186/lib/ruby/gems/1.8/gems/odba-1.1.0/lib/odba/connection_pool.rb:59:in `connect'
        from /usr/local/bin/ruby186/lib/ruby/gems/1.8/gems/odba-1.1.0/lib/odba/connection_pool.rb:59:in `synchronize'
        from /usr/local/bin/ruby186/lib/ruby/gems/1.8/gems/odba-1.1.0/lib/odba/connection_pool.rb:59:in `connect'
        from /usr/local/bin/ruby186/lib/ruby/gems/1.8/gems/odba-1.1.0/lib/odba/connection_pool.rb:22:in `initialize'
        from /usr/local/share/src/bbmb/lib/bbmb/persistence/odba.rb:38:in `new'
        from /usr/local/share/src/bbmb/lib/bbmb/persistence/odba.rb:38
        from /usr/local/bin/ruby186/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in `gem_original_require'
        from /usr/local/bin/ruby186/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in `require'
        from ./bin/bbmbd:18

bbmb expects pg.
This is old wrong constant name (maybe comes from portage version pg). Constant of Ruby is CONSTANT or Constant.

fastpower bbmb $ grep -r pg lib/
lib/bbmb/persistence/odba.rb:  ODBA.storage.dbi = ODBA::ConnectionPool.new("DBI:pg:#{@config.db_name}",
commit

Finaly, I could boot bbmbd.


Setup daemontools

fastpower sandoz.bbmb.ch # svc -u /service/sandoz.bbmb.ch
svc: warning: unable to control /service/sandoz.bbmb.ch: file does not exist

This reason was duty log and supervise directries. (Because these comes from backup with scp.)
I removed these directries (These are created automaticaly), then deamontools also works.

/service/sandoz.bbmb.ch/run
#!/bin/sh
DIR=/var/www/sandoz.bbmb.ch/
LIB=/usr/local/share/src/bbmb/lib
exec 2>&1
exec sudo /usr/local/bin/ruby186/bin/ruby -rubygems -I$LIB $DIR/bin/bbmbd config=$DIR/etc/config.yml                                                                                                 

Permisison problem for database

Got permisson error to connect Database.

2013-06-13 09:31:39.597845500 /usr/local/bin/ruby186/lib/ruby/site_ruby/1.8/dbd/pg/database.rb:82:in `initialize': could not connect to server: Permission denied (DBI::OperationalError)
2013-06-13 09:31:39.597851500   Is the server running locally and accepting
2013-06-13 09:31:39.597852500   connections on Unix domain socket "/run/postgresql/.s.PGSQL.5432"?
2013-06-13 09:31:39.597862500   from /usr/local/bin/ruby186/lib/ruby/site_ruby/1.8/dbd/Pg.rb:157:in `new'
2013-06-13 09:31:39.597863500   from /usr/local/bin/ruby186/lib/ruby/site_ruby/1.8/dbd/Pg.rb:157:in `connect'
2013-06-13 09:31:39.597863500   from /usr/local/bin/ruby186/lib/ruby/gems/1.8/gems/dbi-0.4.5/lib/dbi/handles/driver.rb:33:in `connect'
2013-06-13 09:31:39.597864500   from /usr/local/bin/ruby186/lib/ruby/gems/1.8/gems/dbi-0.4.5/lib/dbi.rb:148:in `connect'
2013-06-13 09:31:39.597865500   from /usr/local/bin/ruby186/lib/ruby/gems/1.8/gems/odba-1.1.0/lib/odba/connection_pool.rb:63:in `_connect'
...

Setup mod_ruby

installed mod_ruby against ruby1.8.6

fastpower src # git clone https://github.com/shugo/mod_ruby.git
fastpower src # cd mod_ruby/
fastpower mod_ruby # /usr/bin/apr-1-config --includedir
/usr/include/apr-1
fastpower mod_ruby # /usr/local/bin/ruby186/bin/ruby ./configure.rb --with-apxs=/usr/sbin/apxs --with-apr-includes=/usr/include/apr-1
...
fastpower mod_ruby # make
fastpower mod_ruby # make install
/usr/bin/install -c -d /usr/lib64/apache2/modules
/usr/bin/install -c -m 555 mod_ruby.so /usr/lib64/apache2/modules
/usr/bin/install -c -d /usr/local/bin/ruby186/lib/ruby/1.8/apache
/usr/local/bin/ruby186/bin/ruby -e "%w!apache/ruby-run.rb apache/registry.rb apache/eruby-run.rb apache/erb-run.rb apache/rd2html.rb apache/ruby-debug.rb apache/eruby-debug.rb apache/ruby-profile.rb apache/rails-dispatcher.rb apache/query.rb auto-reload.rb!.each{|file| system(%Q!#{'/usr/bin/install -c -m 644'} /usr/local/src/mod_ruby/lib/#{file} /usr/local/bin/ruby186/lib/ruby/1.8/#{file}!)}"

Setup apache2 config

Apache2 does not boot for following reasons.

  • directories that does not exists → I moved some conf files in vhosts. (renamed .back, temporary)
  • emerge cronolog → http.conf on fastpower use cronolog instead of logrotate.

/var/log/apache2/error_log

(2)No such file or directory: Couldn't start ErrorLog process
Unable to open logs
view · edit · sidebar · attach · print · history
Page last modified on June 14, 2013, at 07:57 PM