Search  

Deep in Marvin's thorax gears ground.
busy

Updrift is the home of J. Wade Winningham. He helps make the web work.

ThinkingSphinx Capistrano tasks

Pat Allan recently released some helpful capistrano tasks you can use to make it easier to deploy your rails apps which use Sphinx and ThinkingSphinx. These simplify the steps from my previous post about this so I’ve also included an update to my deployment setup.

ThinkingSphinx Capistrano Tasks

Each of these currently gets run in your production environment except for the thinking_sphinx:install tasks. I’m sure a patch would be welcome to make this work across any environment.

cap thinking_sphinx:configure Generate the Sphinx configuration file.
cap thinking_sphinx:index Index data.
cap thinking_sphinx:install:sphinx Install Sphinx by source. This currently grabs the current stable version of Sphinx and compiles it.
cap thinking_sphinx:install:ts Install Thinking Sphinx as a gem from GitHub. If you have the plugin installed, there’s no need to do this.
cap thinking_sphinx:rebuild Stop, re-index and then start the Sphinx daemon.
cap thinking_sphinx:restart Stop and then start the Sphinx daemon.
cap thinking_sphinx:shared_sphinx_folder Add the shared folder for sphinx for Sphinx files for the production environment. More on this below.
cap thinking_sphinx:start Start the Sphinx daemon
cap thinking_sphinx:stop Stop the Sphinx daemon

Adding the new Capistrano tasks to your Rails app

If you’re using the Plugin, you don’t have to do anything as they should be loaded automatically for you. If you have any problems deploying, make sure your Capfile is up-to-date.

If you’re using the Gem add this to the top of your config/deploy.rb file:

require 'thinking_sphinx/deploy/capistrano

For either plugin or gem, add the following line at the bottom of the file:

after "deploy:setup", "thinking_sphinx:shared_sphinx_folder"

Using ‘cap thinking_sphinx:shared_sphinx_folder’

I have not personally run across any issues using symlinks, but some people have. Plus, using a symlink can make you go through extra steps during deployment. Now, there’s a new setting you can add to your config/sphinx.yml file to specify the full path to your Sphinx database files like so:

production:
  searchd_file_path: "/path/to/your/app/db/sphinx/production/"

This path will get automatically created if it does not exist.

Updated Method of Deploying a Rails app with ThinkingSphinx

Having a constant path to the Sphinx indexes means you really don’t have to do anything special on deployment assuming it’s already running. If your define_index block in any models are changing frequently, you can add a few lines so you don’t forget about re-indexing. Check out my revised deploy.rb file for details.

Updated deploy.rb file

My updated sample deploy.rb is pastied.

 

Deploying a Rails app with Thinking Sphinx

Now that I’m using Thinking Sphinx I eventually had to deploy it. Since I didn’t find much info about deploying it using Capistrano here’s what I did to get deployments running smoothly.

NOTE: Please see this updated post for more recent info on deploying your apps with Thinking Sphinx.

 

How to get a good designer to do something within your budget

I overheard someone talking about not being able to find a designer to help them with a web project for less than a certain hourly rate. It’s not the hourly rate that matters, it’s the overall cost.

Here are some tips for getting a good designer to help you out regardless of cost:

  • It’s who you know. You need to get out and meet with designers. In the Dallas area, Refresh Dallas is a good venue for this. Sometimes designers need development work, too, so maybe you can sync up on something. Especially if you’re around a big city, there will be a similar group.
  • Better yet, work with good designers. If you do good work, they’ll remember and want to work with you more and give you some slack on price when you need it. They’ll recommend you to others, too.
  • Tell them what you’ve got to spend up front. They’ll tell you what they can do. It’s possible all you need is a one page template and if you ask them to simply design a site, that typically entails much more effort. Some of the better designers I know ask for a budget outright so they know what they can offer within the constraints.
  • If they can’t be of service, ask if they know anyone who could. Designers often know other designers.

 

Me on Tumblr

I’ve decided to setup a Tumblr page where I currently plan to post frequent, short things both professional and personal. Visit http://wadewinningham.tumblr.com.

 

Stay back, IE7!

Inevitably, today on my Windows XP notebook, the automatic update finally told me that it wanted to install IE7. Since I still need IE6 to test with and have IE7 working quite nicely on my MacBookPro in Parallels, I’m not going there.

 

Highscalability.com

http://highscalability.com has loads of useful information for creating very highly scalable sites. Includes a look behind the scenes of both Google and YouTube.

 

Putting Rails gems into the vendor directory

Over on Err The Blog is an article on placing your gems into the vendor directory rather than relying on them being in the environment.

I’ve run into the issue before where a Rails app doesn’t run on a server due to a gem not being installed. Adding them to your application seems like a perfect solution and deals with other computers possibly having various versions of gems installed.

 

Rails Hash Ordering

My expectation was that when I create a hash it’s going to act like a queue and be sorted in the order in which I inserted things. As I found out today, that is definitely not the case.

There is a very easy way that Rails offers to give a hash this behavior and it’s the OrderedHash function found in the ActiveSupport libraries.

my_hash = ActiveSupport::OrderedHash.new

After that initialization, your hash will be maintained in the order you insert things. Something to watch out for.

 

More Articles

‹ Previous     

time tracking