Discussion

Installation of Pentabarf on Oekonux server

General

Ubuntu packages

  • ruby1.8:

    The following NEW packages will be installed:
      libruby1.8 ruby1.8
    • In addition: cd /usr/bin; ln -s ruby1.8 ruby
  • libyaml-ruby:

    The following NEW packages will be installed:
      libyaml-ruby
    • Necessary for rubygems
  • libzlib-ruby:

    The following NEW packages will be installed:
      libzlib-ruby
    • Necessary for rubygems
  • postgresql-8.1:

    The following NEW packages will be installed:
      libpq4 postgresql-8.1 postgresql-client-8.1 postgresql-client-common
      postgresql-common
    
    Creating new cluster (configuration: /etc/postgresql/8.1/main, data: /var/lib/postgresql/8.1/main)...
    Moving configuration file /var/lib/postgresql/8.1/main/pg_hba.conf to /etc/postgresql/8.1/main...
    Moving configuration file /var/lib/postgresql/8.1/main/pg_ident.conf to /etc/postgresql/8.1/main...
    Moving configuration file /var/lib/postgresql/8.1/main/postgresql.conf to /etc/postgresql/8.1/main...
    Configuring postgresql.conf to use port 5432...
  • imagemagick:

    The following NEW packages will be installed:
      imagemagick libice6 libjasper-1.701-1 liblcms1 libmagick9 libsm6 libtiff4
      libxext6
  • librmagick-ruby1.8:

    The following NEW packages will be installed:
      librmagick-ruby1.8
  • libpgsql-ruby1.8:

    The following NEW packages will be installed:
      libpgsql-ruby1.8
  • libopenssl-ruby1.8

  • libfcgi-ruby1.8

  • libxmpp4r-ruby1.8

    • After gem caused trouble
      • Was not found in FCGI context
  • libpq-dev

    • So ruby-postgres can be compiled
  • ruby1.8-dev

    • So ruby-postgres can be compiled
  • rdoc1.8:

    The following NEW packages will be installed:
      irb1.8 libreadline-ruby1.8 rdoc1.8
    • So documentation can be made by gem

Source packages

  • rubygems

    • Package rubygems-1.2.0.tgz
    • ruby setup.rb --no-format-executable
      • Option installs as gem instead of gem1.8
    • Installs to /usr/local/lib/site_ruby/
    • Installation does not complete regularly :-(
      • But runs
      • Probably only a problem with documentation
      • Solved by installing rdoc1.8
  • Pentabarf:

    svn co svn://svn.cccv.de/pentabarf/tags/0.2.13

Gem packages

Database setup

  • Following

  • Cluster runs already

  • Login:

    $ su postgres
    $ psql template1 postgres
  • Create user and database:

    CREATE USER pentabarf WITH ENCRYPTED PASSWORD '********' NOCREATEDB NOCREATEUSER;
    CREATE DATABASE pentabarf WITH OWNER = pentabarf ENCODING = 'UNICODE';
    \q
  • enable PL/pgSQL:

    $ createlang plpgsql pentabarf
  • login to your database

    • Fails on first attempt

    • Added to /etc/postgresql/8.1/main/pg_hba.conf:

      # Give access to pentabarf
      local   pentabarf   pentabarf                         md5
      • Do this before local all catches all
    • Works from every Unix account:

      $ psql pentabarf pentabarf
  • Create tables, views, types, trigger and functions:

    $ cd ~stefan/packages/src/pentabarf-0.2.13/sql
    $ psql pentabarf pentabarf
    \i tables.sql
    \i tables_logging.sql
    \i views-localization.sql
    \i views.sql
    \i trigger.sql
    \i activate_trigger.sql
    \i types.sql
    \i functions.sql
  • Import the initial data for pentabarf:

    \cd data
    \i import.sql
  • Create an initial pentabarf user:

    \cd ..
    \i pentabarf-user.sql

Pentabarf configuration

  • conf/database.yml

    • Adapted it from the template
      • Set password
  • conf/mail.yml

Webserver setup

  • Source tree moved to /srv/www/pentabarf-0.2.13
Webrick setup
  • Tried it:

    $ script/server
    Your config/boot.rb is outdated: Run "rake rails:update".
    $ rake rails:update
    install -c -m 0755 /usr/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/tasks/../../bin/dbconsole script/dbconsole
    install -c -m 0755 /usr/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/tasks/../../bin/performance/request script/performance/request
    install -c -m 0755 /usr/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/tasks/../../bin/process/inspector script/process/inspector
    $ script/server
    /usr/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/initializer.rb:225:in `require_frameworks': no such file to load -- openssl (RuntimeError)
            from /usr/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/initializer.rb:113:in `process'
            from /usr/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/initializer.rb:93:in `run'
            from ./script/../config/environment.rb:10
            from script/server:44
  • Installed libopenssl-ruby1.8

  • Tried again:

    $ script/server
          *******************************************************************
          * config.breakpoint_server has been deprecated and has no effect. *
          *******************************************************************
    
    /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:218:in `establish_connection': development database is not configured (ActiveRecord::AdapterNotSpecified)
            from /usr/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:209:in `establish_connection'
            from /usr/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/initializer.rb:332:in `initialize_database'
            from /usr/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/initializer.rb:120:in `process'
            from /usr/lib/ruby/gems/1.8/gems/rails-2.1.0/lib/initializer.rb:93:in `run'
            from ./script/../config/environment.rb:10
            from script/server:44
    $ script/server --environment=production
    /srv/www/pentabarf-0.2.13/pentabarf/lib/momomoto/base.rb:4: undefined method `require_gem' for main:Object (NoMethodError)
            from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
            from /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:509:in `require'
            from /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:354:in `new_constants_in'
            from /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:509:in `require'
            from /srv/www/pentabarf-0.2.13/pentabarf/lib/momomoto/momomoto.rb:5
            from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:27:in `require'
            from /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:509:in `require'
            from /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:354:in `new_constants_in'
            from /usr/lib/ruby/gems/1.8/gems/activesupport-2.1.0/lib/active_support/dependencies.rb:509:in `require'
            from ./script/../config/environment.rb:55
            from script/server:44
    • require_gem was deprecated and has been removed
      • Changed it in sources to just gem: script/scgi_rails, lib/momomoto/base.rb, lib/pentacards.rb
  • Tried again:

    $ script/server --environment=production
    ./script/../config/environment.rb:91: undefined method `compile_template' for class `ActionView::Base' (NameError)
        from script/server:44
  • rails is probably too new

    • Downgraded to 1.2.6
  • Tried again:

    $ script/server --environment=production
    => Rails application started on http://0.0.0.0:2342
    [2008-07-17 23:11:18] INFO  WEBrick 1.3.1
    [2008-07-17 23:11:18] INFO  ruby 1.8.4 (2005-12-24) [i486-linux]
    [2008-07-17 23:11:18] INFO  WEBrick::HTTPServer#start: pid=30280 port=2342
    • Yahoo!
  • Runs at http://server.oekonux.de:2342/

    • User pentabarf
FCGI setup
  • Holger installed FCGI from source

  • Holger added SSL configuration and basich pentabarf.oekonux-conference.org setup

  • Copied pentabarf/public/.htaccess from htaccess.txt

    • Set:

      RewriteBase /
      • Browser starts at top level of the pentabarf sub-domain
  • Copied pentabarf/public/dispatch.fcgi from dispatch.fcgi.template

  • Created symbolic link /srv/www/pentabarf pointing to checkout directory

  • Set in httpd.conf:

    DocumentRoot /srv/www/pentabarf/pentabarf/public
  • Restarted Apache

  • Added to httpd.conf:

    <Directory "/srv/www/pentabarf/pentabarf/public">
        AllowOverride All
    </Directory>
    • Restarted Apache

    • At least reached Pentabarf

      • But a 500 error
    • Error logged:

      Rails Error: Unable to access log file. Please ensure that /srv/www/pentabarf-0.2.13/pentabarf/log/production.log exists and is chmod 0666. The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.
  • Changed owner to www-run:www-run

    • Set mode of production.log to 0666

    • Restarted Apache

    • Still doesn't work:

      Errno::EACCES: Permission denied - /srv/www/pentabarf/pentabarf/public/../config/../log/fastcgi.crash.log
  • Set mode of /srv/www/pentabarf/pentabarf/public/../config/../log to 0777

    • Restarted Apache
    • Still doesn't work
  • Set absolute path in dispatch.fcgi:

    require "/srv/www/pentabarf/pentabarf/config/environment"
    • Now wants to set a cookie
      • After all
  • [...Several failures later...]

  • log/production.log says xmpp4r is not found

    • Replaced gem with Debian package
    • Restarted Apache
  • Now the authentication is missing!

    • Created /srv/www/conf/pentabarfpasswd by htpasswd
    • Yahoo! Works!

Debugging

Problems with postgres connector
  • Neither ruby-postgres nor libpgsql-ruby1.8 worked well

    • Changed pentabarf/lib/momomoto/datatype/bytea.rb:

      --- bytea.rb.orig       2008-07-02 22:44:26.000000000 +0200
      +++ bytea.rb    2008-07-27 19:55:44.000000000 +0200
      @@ -10,14 +10,43 @@
               data
             end
      
      -      def filter_read( value )
      -        PGconn.unescape_bytea( value )
      +#      def filter_read( value )
      +#        PGconn.unescape_bytea( value )
      +#      end
      +#
      +      def filter_read( s )
      +              if s
      +                result = ''
      +                i, max = 0, s.size
      +                while i < max
      +                  char = s[i]
      +                  if char == ?\\
      +                    if s[i+1] == ?\\
      +                      char = ?\\
      +                      i += 1
      +                    else
      +                      char = s[i+1..i+3].oct
      +                      i += 3
      +                    end
      +                  end
      +                  result << char
      +                  i += 1
      +                end
      +                result
      +              end
             end
      
      -      def filter_write( value )
      -        "'" + PGconn.escape_bytea( value ) + "'"
      -      end
      +#      def filter_write( value )
      +#        "'" + PGconn.escape_bytea( value ) + "'"
      +#      end
      
      +      def filter_write( s )
      +              result = ''
      +              if s
      +                s.each_byte { |c| result << sprintf('\\\\%03o', c) }
      +              end
      +              "'" + result + "'"
      +      end
           end
      
         end
Events of a speaker failed
  • Speaker was not able to see his events

    • Error:

      PGError (ERROR:  function own_events("unknown", "unknown") does not exist
      HINT:  No function matches the given name and argument types. You may need to ad
      d explicit type casts.
    • Patch:

      --- pentabarf/lib/momomoto/functions/own_conference_events.rb.orig     2008-07-02 22:44:25.000000000 +0200
      +++ pentabarf/lib/momomoto/functions/own_conference_events.rb  2008-07-29 14:14:29.000000000 +0200
      @@ -6,7 +6,7 @@
             @query = "SELECT event_id,
                              %person_id% AS person_id,
                              %conference_id% AS conference_id
      -                  FROM (SELECT own_events AS event_id FROM own_events(%person_id%, %conference_id%)) AS events"
      +                  FROM (SELECT own_conference_events AS event_id FROM own_conference_events(%person_id%, %conference_id%)) AS events"
             @fields = {
               :person_id          => Datatype::Integer.new({:parameter=>true}),
               :conference_id      => Datatype::Integer.new({:parameter=>true}),

Database backup

Dump
  • Create database dump with:

    pg_dump --host=localhost --username=pentabarf --verbose --file=$HOME/`date +pentabarf_%FT%T.bak` --format=p pentabarf
Restore
  • Stop Apache to release database:

    /etc/init.d/httpd stop
  • Prepare new database as postgres:

    su postgres
    psql template1 postgres
    DROP DATABASE pentbarf;
    CREATE DATABASE pentabarf WITH OWNER = pentabarf ENCODING = 'UNICODE';
    \q
    createlang plpgsql pentabarf
  • Start Apache:

    /etc/init.d/httpd start
  • Restore database:

    psql -h localhost -U pentabarf -d pentabarf -f <your backup file here>

StefanMerten/Technics/PentabarfInstallation (last edited 2009-06-02 16:56:39 by StefanMerten)

Creative Commons License
This work is licensed under a Creative Commons License (details).
All pages are immutable until you log in