Recipes: Ferret

March 24th, 2008

Ferret (http://ferret.davebalmain.com/trac) is a high-performance, full-featured text search engine library written for Ruby.

It is inspired by Apache Lucene Java project.

acts_as_ferret comes with a built in DRb server that acts

as the central hub for all indexing and searching in your application.

Ferret now comes with a recipe for managing your Drb server. The Ferret config file is located at config/ferret_server.yml and

looks like this:

production:
host: ferret.yourdomain.com
port: 9009
pid_file: log/ferret.pid

The supplied recipe looks like this

namespace :ferret do
desc “Stop the Ferret server, and continue even if the operation fails.”
task :stop_safe, :roles => :app, :o n_error => :continue do
top.ferret.stop
end

desc “Start Ferret Server”
task :start, :roles => :app do
top.ferret.start
end

desc “Stop Ferret Server”
task :stop, :roles => :app do
top.ferret.stop
end

desc “Restart Ferret Server”
task :restart, :roles => :app do
top.ferret.restart
end

desc “Rebuild the Ferret index”
task :rebuild, :roles => :app do
run “cd #{current_path} && rake production ferret:rebuild”
end

desc “Destroy the Ferret index”
task :destroy, :roles => :app do
run “cd #{current_path} && rm -rf index/production index/development index/test”
end

end

.caprc (the capistrano dotfile)

March 24th, 2008

As of revision 5774, capistrano  has a  default  dotfile.

Here’s how dotfiles work in edge capistrano:

* The dotfile, by default, is called “.caprc” and will be searched
for in your home directory. On Unices, this is the ENV["HOME"]
variable. On windows, it is “#{ENV["HOMEDRIVE"]}#{ENV["HOMEPATH"]}”.
The environment is searched in that order (so if you have HOME set on
Windows, it will be used), and if none is found the root directory is
used.

* You can override the path to the config file via the -c switch:
“cap -c /path/to/.customrc …”

* You can specify that you don’t want to use the config file at all
via the -x switch: “cap -x …”

* The file will be loaded immediately after the “-S” options are
processed. Thus, variables you set via -S will be available to
the .caprc stuff.

The major difference between the patch you submitted and the way I
implemented it is that the .caprc will always be loaded, whether or
not other recipe files are specified. (As I mentioned above, you can
skip the config loading with -x.)

[From Jamis buck on the mailing list ]

Webservers : Lightspeed

March 24th, 2008

namespace :deploy do
task :restart do
sudo “/usr/local/lsws/bin/lswsctrl restart”
end

task :stop do
sudo “/usr/local/lsws/bin/lswsctrl stop”
end

task :start do
sudo “/usr/local/lsws/bin/lswsctrl start”
end

end

Webservers: Thin

March 24th, 2008

If you are using the Thin webserver you can add  the following to you deploy file to restart support restarting  Thin

namespace :deploy do
task :start do
sudo “/etc/init.d thin start”
end
task :stop do
sudo “/etc/init.d thin stop”
end
task :restart do
sudo “/etc/init.d thin restart”
end
end

Checking out from your local file system

March 24th, 2008

If you can’t use a SCM from your server for  whatever reason you can use

set :deploy_via, :copy

to compress and upload your code from your development machine.

Here is an example and some setting that you can use :

set :deploy_via, :copy

# the source is checked out first before it is compressed and uploaded

# this specified how this happens export or checkout

set :copy_strategy, :export

set :copy_remote_dir, “some_tmp_path” # it defaults to /tmp

set :copy_compression, :zip       # :zip or :gzip, :bz2

What is default_run_options[:pty] ??

March 24th, 2008

This setting specifies the value for pseudo terminals in Capistrano, the default value is false

As of version 2.1, Capistrano no longer requests that a pty be
allocated for each command. This means that your default profile
settings will be loaded automatically for every command.

You can override the default setting for an individual command by adding :pty => true.

For more information on ssh and shells including Pseudos terminals:  http://net-ssh.rubyforge.org/chapter-5.html

More on Pseudo terminals in general : http://en.wikipedia.org/wiki/Pseudo_terminal

Checking out from Git

March 24th, 2008

ssh_options[:port] = some_port_number
set :scm, :git
set :branch,  “stable”
set :scm_url, “staging” # In actuality, this is set to the IP address
set :scm_passphrase, proc { Capistrano::CLI.password_prompt(“SSH
passphrase: “) }

set :repository,  “#{scm_user}@#{scm_url}:project.git”
set :remote, scm_user # Set in ~/.caprc
set :repository_cache, “git_master”
set :deploy_via, :remote_cache

[to_cleanup]

Checking out from http+svn

March 24th, 2008

Setup your variables like so:

set :svn_username, “username”
set :svn_password, “password”
set :projectname, “my_project”

set :repository, “http://my_svn_server.org/repos/#{projectname}/trunk/”

To prevent being asked for password, you may need to check out a project from your repository once from the account you deploy with, on the server.

[to_clarify]

Answer: 60,000 v’s 90,000

November 28th, 2005

Thats is the answer to my question, apparently 60,000 people are employed by Irish companies in the US [1], where as 90,000 Irish people [2] are hired directly by US companies in Ireland.

Interesting fact I think.

[1] Brian Cowen on RTE news.
[2] www.amcham.ie/article.cfm?idarticle=315

How to cross the road (in Phnom Penh, Cambodia)

October 27th, 2005

Ok, I admit it. It took about 10 minutes to cross the street in Phnom Penh for the first time.

I was standing outside my hotel. On the otherside of the road were the banks of Mekong River. Between us: Chaos.

Motorbikes, tuk-tuks, trunks, bicycles; all going in different directions, at different speeds.

Stop, Look, Listen

Green Cross Code Man

I meekly step out into fray. Shit, a moto, step back. It passes. Once more into the void; I step out again, a shout from behind me, back again. Locals are looking at me. Children are laughing. Oh, Green Cross Code Man , where are you?

Moses stretched out his hand over the sea, …The waters were divided

Right, I didn’t come 10,000 miles to be stopped by a busy road!
Chin up, back straight, walk. It worked. The streams of traffic slowed or adjusted course to allow me to pass, without one tut of a horn or an angry gesture. I had made it to the banks of the Mekong.

Guess thats how you cross the road in Phnom Penh then!