view · edit · sidebar · attach · print · history

Make sure we are running the right version of Ruby

$ eselect ruby show
Current Ruby version:
  ruby19                    
Current Rubygems version:
  gem19                

Check also postgresql version

$ eselect postgresql show
8.4

$ rc-status
Runlevel: default
 postgresql-8.4          

Launching oddbd

$ cd /var/www/oddb.org
$ bin/oddbd

Several errors of the following type, which can be ignored for the time being
ERROR: relation "object" already exists

The error that needs to be fixed now is
process: Oddb (OddbApp)
init system
/home/alex/.gem/ruby/1.9.1/gems/odba-1.0.8/lib/odba/marshal.rb:15:in `load': undefined class/module CSV::Cell (ArgumentError)

This error will need to be solved by applying the patch
http://dev.ywesee.com/uploads/att/csv.rb.patch.20111123.txt
Save it to my home folder

$ sudo updatedb
Password: 
$ locate csv.rb
/home/alex/csv.rb.patch.20111123.txt
/usr/lib64/ruby/1.8/csv.rb
/usr/lib64/ruby/1.9.1/csv.rb
/var/www/oddb.org/src/state/companies/fipi_csv.rb
/var/www/oddb.org/src/view/companies/fipi_csv.rb
/var/www/oddb.org/test/test_view/companies/fipi_csv.rb

$ cd /usr/lib64/ruby/1.9.1/
$ sudo patch -p 0 < ~/csv.rb.patch.20111123.txt

Milestone: oddbd is now running: it proceeds to printing
system initialized
(still some errors are displayed, but they can be ignored)

Yaml

$ sudo emerge yaml

Apache

$ sudo emerge apache

$ sudo /etc/init.d/apache2 start
Password: 
 * Starting apache2 ...
apache2: apr_sockaddr_info_get() failed for alex
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
 * start-stop-daemon: failed to start `/usr/sbin/apache2'

It doesn't appear to be running, despite

$ rc-status
Dynamic Runlevel: manual
 apache2

$ sudo /etc/init.d/apache2 status
 * status: started

$ ps aux | grep apache2
alex      2934  0.0  0.0   8360   880 pts/0    S+   10:10   0:00 grep --colour=auto apache2

Stopped the server and checked the error log file

$ sudo /etc/init.d/apache2 stop
$ sudo cat /var/log/apache2/error_log
[Fri May 04 10:01:22 2012] [alert] (EAI 2)Name or service not known: mod_unique_id: unable to find IPv4 address of "alex"
Configuration Failed

Locate the configuration file

$ locate httpd.conf
/etc/apache2/httpd.conf
Got rid of the first error about apr_sockaddr_info_get() by appending this line to the end of the configuration file
ServerName localhost
$ sudo vim /etc/apache2/httpd.conf

Now starting apache

$ sudo /etc/init.d/apache2 start
 * Starting apache2 ...
 * start-stop-daemon: failed to start `/usr/sbin/apache2'

Check the hostname

$ cat /etc/conf.d/hostname 
# Set to the hostname of this machine
hostname="alex"

$ hostname
alex

Fixed the remaining problem by modifying the hostname and restarting the server

$ hostname localhost
$ sudo /etc/init.d/apache2 restart
 * apache2 not running (no pid file)
 * Starting apache2 ...     

Milestone: http server works for localhost
http://localhost

$ sudo vim /etc/hosts
127.0.0.1       localhost
127.0.0.1       localhost       oddb.alex.org

Wrong way of creating the virtual host configuration file:

$ cd /etc/apache2/vhosts.d/
$ sudo cp 00_default_vhost.conf 01_oddb_vhost.conf
$ sudo vim 01_oddb_vhost.conf
changed from
    ServerName localhost
to
    ServerName oddb.alex.org

Correct way of creating the virtual host configuration file:

$ cd /etc/apache2/vhosts.d/
$ wget http://dev.ywesee.com/uploads/att/02_oddb_vhost.conf.txt

Then edit the file to have the correct
ServerName oddb.alex.org
and sbsm version
RubyAddPath /home/alex/.gem/ruby/1.9.1/gems/sbsm-1.1.6/lib
which was discovered from the gem list command


$ sudo vim /etc/conf.d/apache2
added "-D RUBY" to APACHE2_OPTS
$ sudo /etc/init.d/apache2 restart
Password: 
 * apache2 has detected an error in your setup:
Syntax error on line 16 of /etc/apache2/vhosts.d/01_oddb_vhost.conf:
Invalid command 'RubyAddPath', perhaps misspelled or defined by a module not included in the server configuration
 * ERROR: apache2 failed to stop

Next: I need to get mod_ruby and compile it against ruby 1.9

mod_ruby

In principle, there are two possible ways of proceeding:

  • either by emerging mod ruby
  • or by cloning the git repository and compiling the sources

The second way is the preferred one, because the same procedure will need to be repeated later on to compile it against ruby 1.8

$ cd ~/sw
$ git clone https://github.com/shugo/mod_ruby.git
$ cd mod_ruby
$ sudo /usr/bin/ruby ./configure.rb --with-apxs --with-apr-includes=/usr/include/apr-1
$ sudo make
$ sudo make install

$ cd ~
$ wget http://dev.ywesee.com/uploads/att/21_mod_ruby.conf.txt
$ mv 21_mod_ruby.conf.txt 21_mod_ruby.conf
$ sudo mv 21_mod_ruby.conf /etc/apache2/modules.d/

$ /etc/init.d/apache2 restart

Start (or restart) apache

$ sudo /etc/init.d/apache2 start
 * Starting apache2 ... 

Browsing to
http://oddb.alex.org
no longer displays "Unable to connect"
but "Internal Server Error"

Stopped the server and checked the error log file

$ sudo /etc/init.d/apache2 stop
$ sudo cat /var/log/apache2/error_log
[Fri May 04 11:34:07 2012] [error] mod_ruby: error in ruby
[Fri May 04 11:34:07 2012] [error] mod_ruby: /usr/lib64/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- /usr/local/lib/ruby/gems/1.9.1/gems/sbsm-1.1.6/lib/sbsm/request (LoadError)
[Fri May 04 11:34:07 2012] [error] mod_ruby:   from /usr/lib64/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
[Fri May 04 11:34:07 2012] [error] mod_ruby:   from /var/www/oddb.org/doc/index.rbx:7:in `<top (required)>'
[Fri May 04 11:34:07 2012] [error] mod_ruby:   from /usr/lib64/ruby/1.9.1/apache/ruby-run.rb:53:in `load'
[Fri May 04 11:34:07 2012] [error] mod_ruby:   from /usr/lib64/ruby/1.9.1/apache/ruby-run.rb:53:in `handler'
ruby: warning: already initialized constant TMP_RUBY_PREFIX
ruby: warning: already initialized constant TMP_RUBY_PREFIX
ruby: warning: already initialized constant TMP_RUBY_PREFIX
ruby: warning: already initialized constant TMP_RUBY_PREFIX
ruby: warning: already initialized constant TMP_RUBY_PREFIX
ruby: warning: already initialized constant TMP_RUBY_PREFIX
[Fri May 04 11:35:53 2012] [notice] caught SIGTERM, shutting down

The error is due to the fact that mod ruby is trying to find the sbsm gem in
/usr/local/lib/ruby/gems/1.9.1/gems/sbsm-1.1.6/lib/sbsm/
instead of
/home/alex/.gem/ruby/1.9.1/gems/sbsm-1.1.6/lib/sbsm

$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.15
  - RUBY VERSION: 1.9.3 (2011-10-30 patchlevel 0) [x86_64-linux]
  - INSTALLATION DIRECTORY: /home/alex/.gem/ruby/1.9.1
  - RUBY EXECUTABLE: /usr/bin/ruby19
  - EXECUTABLE DIRECTORY: /home/alex/.gem/ruby/1.9.1/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /home/alex/.gem/ruby/1.9.1
     - /usr/local/lib64/ruby/gems/1.9.1
     - /usr/lib64/ruby/gems/1.9.1
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

Interesting information in

$ cat /usr/lib64/ruby/site_ruby/1.9.1/rubygems/custom_require.rb

  # When RubyGems is required, Kernel#require is replaced with our own which
  # is capable of loading gems on demand.
  #
  # When you call <tt>require 'x'</tt>, this is what happens:
  # * If the file can be loaded from the existing Ruby loadpath, it
  #   is.
  # * Otherwise, installed gems are searched for a file that matches.
  #   If it's found in gem 'y', that gem is activated (added to the
  #   loadpath).
  #
  # The normal <tt>require</tt> functionality of returning false if
  # that file has already been loaded is preserved.

This is the lead to the right solution to the problem:

$ sudo vim /var/www/oddb.org/doc/index.rbx
replaced
require '/usr/local/lib/ruby/gems/1.9.1/gems/sbsm-1.1.6/lib/sbsm/request'
with
require '/home/alex/.gem/ruby/1.9.1/gems/sbsm-1.1.6/lib/sbsm/request'

Start (or restart) apache

$ sudo /etc/init.d/apache2 restart
 * Starting apache2 ...

Milestone: the server appears to be running, showing the open drug database colorful home page,
but with the following message:
We are sorry
The application is currently down due to a software-update

Launching oddbd

$ cd /var/www/oddb.org
$ bin/oddbd

the browser refreshed itself and the main page got displayed

Currency deamon

$ sudo gem install ycurrency
$ currencyd &

Milestone: now when we do a search for a drug the results are displayed correctly

yus (ywesee user Server)

Rationale

  • a user can only do up to 5 searches within 24 hours, unless yus is installed.

Notes

  • yus needs Ruby 1.8 because it hasn't been updated yet to run with Ruby 1.9

Reference links

Acquire the sources

$ cd ~/sw
$ git clone git://scm.ywesee.com/yus/.git yus

Now read the document
yus/Guide.txt

Switch to Ruby 1.8

$ eselect ruby list
Available Ruby profiles:
  [1]   ruby18 (with Rubygems)
  [2]   ruby19 (with Rubygems)
alex@localhost ~ $ sudo eselect ruby set 1
Successfully switched to profile:
  ruby18                    

$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.15
  - RUBY VERSION: 1.8.7 (2011-12-28 patchlevel 357) [x86_64-linux]
  - INSTALLATION DIRECTORY: /home/alex/.gem/ruby/1.8
  - RUBY EXECUTABLE: /usr/bin/ruby18
  - EXECUTABLE DIRECTORY: /home/alex/.gem/ruby/1.8/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /home/alex/.gem/ruby/1.8
     - /usr/local/lib64/ruby/gems/1.8
     - /usr/lib64/ruby/gems/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/
alex@localhost ~ $ gem -v
1.8.15
alex@localhost ~ $ gem list

*** LOCAL GEMS ***

deprecated (2.0.1)
json (1.6.4)
pg (0.13.2)
racc (1.4.7)
rake (0.9.2.2)
rdoc (3.12)
$ sudo gem install needle --version '=1.3.0'
$ sudo gem install pg --version '=0.9.0'
$ sudo gem install postgres --version '=0.7.9.2008.01.28'
$ sudo gem install ruby-password

Note: it installs
ruby-password (0.15.5)
but Guide.txt says to install
ruby-password (0.5.3) from sources
We shall not worry so much about this for the moment.

At this point yus is not installed for ruby 1.8 yet, so if I try to start yus, this is what happens:

$ locate yusd
/home/alex/.gem/ruby/1.9.1/bin/yusd
/home/alex/.gem/ruby/1.9.1/gems/yus-1.0.0/bin/yusd

$ /home/alex/.gem/ruby/1.9.1/bin/yusd 
/home/alex/.gem/ruby/1.9.1/gems/needle-1.3.0/lib/needle/definition-context.rb:36: warning: undefining `initialize' may cause serious problems
/home/alex/.gem/ruby/1.9.1/gems/needle-1.3.0/lib/needle/definition-context.rb:36: warning: undefining `object_id' may cause serious problems
/home/alex/.gem/ruby/1.9.1/gems/needle-1.3.0/lib/needle/definition-context.rb:36: warning: undefining `__send__' may cause serious problems
/home/alex/.gem/ruby/1.9.1/gems/dbi-0.4.5/lib/dbi.rb:300:in `block in load_driver': Unable to load driver 'pg' (underlying error: wrong constant name pg) (DBI::InterfaceError)

Note how all the paths are pointing to the wrong version.

$ sudo gem install yus
$ gem list yus
*** LOCAL GEMS ***
yus (1.0.0)

$ sudo mkdir -p /etc/yus/data

$ locate yus.crt
/home/alex/.gem/ruby/1.9.1/gems/yus-1.0.0/data/yus.crt
/home/alex/sw/yus/data/yus.crt
/usr/local/lib64/ruby/gems/1.8/gems/yus-1.0.0/data/yus.crt
$ locate yus.key
/home/alex/.gem/ruby/1.9.1/gems/yus-1.0.0/data/yus.key
/home/alex/sw/yus/data/yus.key
/usr/local/lib64/ruby/gems/1.8/gems/yus-1.0.0/data/yus.key

Maybe it would be okay to use the existing yus.crt and yus.crt from one of the locations above, and copying them to the intended destination, but we might as well go ahead and generate new keys and certificates:

Create public/private keys

$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/alex/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/alex/.ssh/id_rsa.
Your public key has been saved in /home/alex/.ssh/id_rsa.pub.
The key fingerprint is:
b4:99:d7:c1:63:c9:02:ae:db:ec:05:65:51:0f:2c:86

Generate certificate (left all info blank by pressing the ENTER key immediately at each prompt)

$ cd ~
$ openssl req -new -x509 -key .ssh/id_rsa -out .ssh/id_rsa.crt
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:
Email Address []:

Copy the key and certificate into the intended folder where the yaml configuration file is expecting them

$ sudo cp /home/alex/.ssh/id_rsa /etc/yus/data/yus.key
$ sudo cp /home/alex/.ssh/id_rsa.crt /etc/yus/data/yus.crt

yaml

$ locate sha256.rb
/home/alex/.gem/ruby/1.9.1/gems/yus-1.0.0/sha256.rb
/home/alex/sw/yus/sha256.rb
/usr/local/lib64/ruby/gems/1.8/gems/yus-1.0.0/sha256.rb

$ ruby /usr/local/lib64/ruby/gems/1.8/gems/yus-1.0.0/sha256.rb hatakeyama2
password: hatakeyama2
SHA256 encoding: 8fc68bf10a98d0a3874aaefa546edd4ec5e3f04b1a777310e9b1c798ef698d93
$ sudo vim /etc/yus/yus.yml
root_name: alex@filzmail.com
root_pass: 8fc68bf10a98d0a3874aaefa546edd4ec5e3f04b1a777310e9b1c798ef698d93
log_level: DEBUG
ssl_key: /etc/yus/data/yus.key
ssl_cert: /etc/yus/data/yus.crt
session_timeout: 3600

Try to add the user

$ yus_add_user alex@filzmail.com login org.oddb.RootUser
/usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require': no such file to load -- rclconf (LoadError)

$ gem install rclconf
$ yus_add_user alex@filzmail.com login org.oddb.RootUser
/usr/lib64/ruby/1.8/drb/drb.rb:736:in `open': drbssl://localhost:9997 - #<Errno::ECONNREFUSED: Connection refused - connect(2)> (DRb::DRbConnError)

Note: yusd must be running before we can add the user

$ yusd
/usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require': no such file to load -- odba (LoadError)

$ gem install odba

$ yusd
/usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require': no such file to load -- dbi (LoadError)

$ gem install dbi

$ yusd
/usr/local/lib64/ruby/gems/1.8/gems/yus-1.0.0/lib/yus/server.rb:9: warning: already initialized constant VERSION
/home/alex/.gem/ruby/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)

SETUP POSTGRES DB

alex$ sudo su - postgres
Password:
postgres$ createuser yus
(replied 'n' to all 3 questions)

postgres$ createdb yus
postgres$ exit
alex$

$ cd ~/sw/yus
$ ruby bin/yusd
/home/alex/sw/yus/lib/yus/server.rb:9: warning: already initialized constant VERSION
/home/alex/.gem/ruby/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)
$ sudo emerge =ruby-dbi-0.4.3
$ sudo emerge =pg-0.12.2
$ sudo emerge =dbd-pg-0.3.9
$ ruby bin/yusd
/usr/lib64/ruby/site_ruby/1.8/dbi/utils/date.rb:57: undefined method `deprecate' for DBI::Date:Class (NoMethodError)

Note:

  • yusd must be running before we can add a user

Removed deprecated(3.0.0)

$ gem uninstall deprecated

Changed yus.key permissions

$ ls -la /etc/yus/data/
-rw------- 1 root root 1675 May  4 15:17 yus.key
$ sudo chmod 644 /etc/yus/data/yus.key
$ ls -la /etc/yus/data/
-rw-r--r-- 1 root root 1675 May  4 15:17 yus.key
$ yusd
/usr/local/lib64/ruby/gems/1.8/gems/yus-1.0.0/lib/yus/server.rb:9: warning: already initialized constant VERSION
ERROR:  relation "object" already exists
ERROR:  relation "prefetchable_index" already exists
ERROR:  relation "extent_index" already exists
ERROR:  relation "object_connection" already exists
ERROR:  relation "target_id_index" already exists
ERROR:  relation "collection" already exists
I, [2012-05-04T16:33:52.956793 #13783]  INFO -- start: starting yus-server on drbssl://localhost:9997

Milestone: now yusd is running

Reference:

Created temporary email address to receive the password
http://filzmail.com/
alex@filzmail.com

Actually, it turns out that it needs to be a gmail address (this functionality has only been tested with gmail)

Add the user

$ yus_add_user alex@filzmail.com login org.oddb.RootUser
/usr/lib64/ruby/1.8/drb/drb.rb:736:in `open': drbssl://localhost:9997 - #<Errno::ECONNREFUSED: Connection refused - connect(2)> (DRb::DRbConnError)

$ yus_add_user alex@filzmail.com login org.oddb.RootUser
Password for alex@filzmail.com: hatakeyama2
New Password for alex@filzmail.com: alex
Repeat Password for alex@filzmail.com: alex

Then try logging in from the web interface
(Login link at the bottom right of the home page)
specify E-mail: alex@filzmail.com
and password: alex

but it's not going to work because we need to click on "Lost password ?" to receive an email to a valid gmail account

  • Created gmail account "alex.funtoo@gmail.com"
  • Entered "alex.funtoo@gmail.com" in login page and clicked "Lost password ?"

Updated oddb.yml with new email account information

$ sudo cp oddb.yml /var/www/oddb.yml

Restarted oddb

$ sudo eselect ruby set 2
$ bin/oddbd

TODO:

  • $ yus_grant alex@filzmail.com edit yus.entities
view · edit · sidebar · attach · print · history
Page last modified on May 04, 2012, at 06:00 PM