Friday, February 22, 2008

subversion troubles...

This is the second time I have had subversion troubles. So I wanted to write down some of the steps I followed to cure the trouble.
Symptom: Database has become corrupted...
Solution:
kill svnserve
svnadmin recover /path/to/repos
then:
chgrp -R subversion /home/svn
chmod -R 770 /home/svn
chmod g+s /home/svn/db
restart svnserve: svnserve --daemon --root /home/svn

Thursday, February 21, 2008

Sorting and filtering...

I finished the sorting and filtering for the companies page. It was a bit of a pain. For the sorting, I used a RAils plugin called sortable_column_headers. I attempted to install it into our application, but it kind of failed to be able to commit it to the SVN. I'll have to learn how to do that later.

For now, you should open the rails plugins view, select sortable_column_headers and check svn:externals and svn:checkout install and then click GO.

But the searching works just fine. Next, I would like it to filter the results as you type. That would be much more useful.

Wednesday, February 13, 2008

Finished deployment to VPS

There was nothing instant about getting rails deployed to the server, but now that it is there, it should be fairly trivial to deploy new instances from now on.

I had to combine the strengths of Dave Stevenson (SilverRack) and the Agile Web Development with Rails book. There were a few gotchas along the way that I will attempt to address here. In the meantime though, you should be able to access the website here:

http://216.194.127.249/company/list

I'm gonna list the gotchas now, but they may not be in any particular order.
  • An SVN client must be installed on my windows box
  • mongrel_rails cluster::configure command produces a mongrel_cluster.yml file that tells capistrano to look for files in the 'conf' directory instead of the config directory, so after executing that step, it is very important to edit the file appropriately.
  • replace cap --apply-to .... with 'capify .' This was no doubt a new command that didn't exist at the time of publishing
  • In the deploy.rb file, you can add the following entries to make it connect correctly (asterisks added for security):
  • set :user, "root"
    set :svn_username, "*****"
    set :svn_password, "******"
  • cap setup has changed to cap deploy:setup. This only has to be run one time to get all of th right directories in place
  • The /var/www/apg/current directory is actually a symlink that points to another directory under releases. This allows capistrano to maintain several versions of the product, and switch between them with ease.
  • cap cold_deploy changed to cap deploy:cold
  • I had missed the right port numbers in the vhost.conf file. Since the mongrel_cluster.yml file specifies two mongrel threads listening on 8000, and 8001, then the vhost.conf file must also point to 8000 and 8001
  • I found that apache on linux has multiple configuration files all under /etc/httpd/conf.d
  • Only Apache 2.2 supports the mongrel mod and the subversion dav_svn_module. So Apache 2.2 is essential
  • When running capistrano, it starts up the mongrel servers in production mode with a -e production parameter to specify the rails app should use the production server
  • I had to manually run the 'rake db:dbdata:load' command on the application because the rake db:migrate tool didn't have that as part of it.
  • In order to allow http access to SVN, I had to change the ownership on the subversion directories /home/svn. I used the command 'chown -R apache.subversion /home/svn'
  • Centos 4 didn't have the yum repository that includes mysql5 or apache 2.2 so I had to integrate with a repository that Dave Stevenson sent me:

(need to add the exact yum line here)

yum --disablerepo=update --disablerepo=base -y install gcc openssl-devel> mod_perl-devel mod_python mod_ssl mod_dav_svn mysql-server mysql-devel> libpng-devel libjpeg-devel libtiff-devel freetype-devel ghostscript-devel> which>> yum --disablerepo=update --disablerepo=base -y update

  • I still need to configure the database passwords to be taken from a shared location, instead of checked into the database. For now then, I have changed the passwords for the database and modified the file on the server for security.

Saturday, February 9, 2008

new info from Dave

Dave's response to my message about it not working still.



Hi Brent -That message is because Apache 2.2 isn't installed.The yum update from the utterramblings repo should've done it. But - I checked your system and it wasn't working. I tried a few things and finally got some stuff to work.Rerun the 2 yum commands like this (notice the disabling of the update and base repositories)yum --disablerepo=update --disablerepo=base -y install gcc openssl-devel mod_perl-devel mod_python mod_ssl mod_dav_svn mysql-server mysql-devel libpng-devel libjpeg-devel libtiff-devel freetype-devel ghostscript-devel whichyum --disablerepo=update --disablerepo=base -y updateYou should notice that all of the files are coming from the utterramblings repository - and that apache will be version 2.2, mysql will be 5x,etc. Dave
On Feb 9, 2008 10:07 AM, Brent Fisher <
bc.fisher@yahoo.com> wrote:
I went through the steps, but when I try to start, it says this:

login as: root
root@216.194.127.249's password:Last login: Fri Feb 8 22:16:39 2008 from 71-213-85-69.slkc.qwest.net[root@apgtest ~]# httpd -k startSyntax error on line 2 of /etc/httpd/conf.d/httpd-vhosts.conf:Invalid command 'BalancerMember', perhaps mis-spelled or defined by a module not included in the server configuration[root@apgtest ~]#
perhaps the load balancer mod isn't installed still? It did have a little bit of trouble with some of the mirror sites when I executed the yum update command. Could that have been the problem?
Brent Fisher
I can help
bc.fisher@yahoo.com
highlandfishers.com
801.842.1114

This seemed to work

Friday, February 8, 2008

Installing in production continued...

I'm continuing on, it says...
vi /etc/https/conf/httpd.conf, comment out mod_ssl, change DocumentRoot to valid folder)

I talked to Dave at silverrack, he recommended that I could use /tmp or /var/www/html. it isn't used with rails apps, but if it isn't valid, then apache will complain...
Turns out, I didn't have to do anything on this step.

vi /etc/httpd/conf/httpd.conf - uncomments the reference to /extra/httpd-vhosts.conf no-op. its enabled by default...(says Dave from silverrack)

Thursday, February 7, 2008

Installing instant rails

Download instant rails from:

http://rubyforge.org/frs/?group_id=904

download 1.7
InstantRails-1.7-win.zip

copy the file to your root directory and unzip it there. It won't work otherwise. Then just run instant rails setup.

Installing in production - rails install.

I am attempting to install rails by following the guide on this page from the SilverRack blog:

https://silverrack.com/posts/1

It seems to be ok, but you should know that you will have to compile some stuff, so it is missing the part where you do that. You can do that using:

yum install gcc*

The ftp sit he listed doesn't have that file anymore, so I had to just 1.8.5 without the p12.

I also didn't know how to get the file from the http protocol, but I'm trying to use wget instead.

wget worked perfect. so did the gems install. so far, so good!

when I attempted

gem install rmagick

It didn't work. It complained: Can't find libMagick or one of the dependent libraries. Check the mkmf.log file for more detailed information.

I'm gonna try skipping that. I'm not sure I need RMagick (what is it...)

Everything worked fine until:
make && make install from gem directory
it gave me:
[root@apgtest mysql-2.7]# make && make install from gem directorygcc -I. -I. -I/usr/local/lib/ruby/1.8/i686-linux -I. -DHAVE_MYSQL_SSL_SET -DHAVE_MYSQL_H -I/usr/include/mysql -g -pipe -m32 -march=i386 -mtune=pentium4 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fPIC -g -O2 -c mysql.cgcc -shared -L'/usr/local/lib' -Wl,-R'/usr/local/lib' -o mysql.so mysql.o -L/usr/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -L/usr/lib -lssl -lcrypto -ldl -lcrypt -lm -lc/usr/bin/install -c -m 0755 mysql.so /usr/local/lib/ruby/site_ruby/1.8/i686-linuxmake: *** No rule to make target `from'. Stop.

I realized I was kind of stupid. I should have left off the 'from gem directory'. I think it probably worked just fine.

It's late: 12:58 AM. I just started on this line:
vi /etc/httpd/conf/httpd.conf (comment out mod_ssl, change DocumentRoot to valid folder)
I'll work on it a bit more another day...

Wednesday, February 6, 2008

using aptana to get your code from svn.

In order to use svn with aptana, I did the following:

I had to install the subclipse plugin. To do this, look for it in the aptana plugin manager. Right click, select install.

After installation:

Select Windows->Preferences->Team->SVN: Check SVNKit (Pure Java)

Then switch to the SVN Repository Exploring Perspective. In the SVN Repository View, click the add location button. Type this in, but replace your name and password...

svn+ssh://brent@216.194.127.249/home/svn

After it is added, navigate to /home/svn/apg/trunk. right-click, select checkout. choose the name as apg. click next, choose the location as your instant rails installation, rails-apps directory.

Now from the config/database.example file, make a copy called config/database.yml. Edit the file as necessary to make it point to your database. If you haven't already, from Instant Rails, open a ruby console and execute the following:

C:\InstantRails\rails_apps\apg>mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 1 to server version: 5.0.27-community

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> create database apg_development
-> ;Query OK, 1 row affected (0.77 sec)

mysql> exit
Bye

C:\InstantRails\rails_apps\apg>rake db:dbdata:load
(in C:/InstantRails/rails_apps/apg) -- msg: retrieving db info -- msg: Loading data into DBmysql -uroot ... [password filtered]

C:\InstantRails\rails_apps\apg>

Now your database is ready to go!

database dump

Added a database dump for the initial migration. Use rake db:dbdata:load to load the data into your database. See http://webchicanery.com/2007/08/22/rake-database-dump/

rake db:dbdata:load RAILS_ENV=production

Tuesday, February 5, 2008

svn accounts created...

I have created svn accounts for all developers:
doug:
david:
brent:

for the password, please call me.

You can checkout by hitting the server (216.194.127.249) with tortoiseSVN (google it, download it). Go to the directory where you want to work.

E.g. C:\Rails-1.7\InstantRails\rails_apps Right click, select SVN-checkout. For the URL, put in:

svn+ssh://doug@216.194.127.249/home/svn/apg/trunk

this will check out the repository to your local directory called apg. This is using a secure encrypted shell to do the work. No worries.

Redadcting the database...

Need to redact Customers.BANK_ROUTE_TRANSIT & BANK_ACCOUNT_NUMBER
companies.CO_ID.

I'm thinking of redacting them by adding a random digit to each digit in the string. This will create a number that is impossible to trace back to the original number, but will still look like the original number.

Here are the queries I performed:

SELECT C.BANK_ACCOUNT_NUMBER, CEIL(C.BANK_ACCOUNT_NUMBER + (C.BANK_ACCOUNT_NUMBER/10 - C.BANK_ACCOUNT_NUMBER/10 * RAND())) AS GEN FROM CUSTOMERS C;

UPDATE CUSTOMERS SET BANK_ROUTE_TRANSIT = CEIL(BANK_ROUTE_TRANSIT + (BANK_ROUTE_TRANSIT/10 - BANK_ROUTE_TRANSIT/10 * RAND()));

UPDATE CUSTOMERS SET BANK_ACCOUNT_NUMBER = CEIL(BANK_ACCOUNT_NUMBER + (BANK_ACCOUNT_NUMBER/10 - BANK_ACCOUNT_NUMBER/10 * RAND()));

This gave us numbers that still looked real, but weren't. :D

Friday, February 1, 2008

The mysql of choice

What should we choose for the mysql administration tool? I have tried the Mysql administrator, but I find that it doesn't have a very good graphical view of the schema. If I use the workbench OSS, it looks ok, but I can't actually show the existing database very well.

Is there a program that will do both for me?