Hi!

I haven’t written for a while now on this blog. Since my last post I moved to a little bit more specific content goal in terms of writing.

In the past, the technical blog posts on this blog were highly popular. I plan to continue them on my new blog, Developer Founder. Here, I will write about my daily activities as founding partner and developer of Firmhouse. Also, I will be posting code samples and other cool technical-related items.

My other new blog is -> Inbound (pronounced: Dash Inbound). On this blog I am planning to write about how you can use inbound marketing techniques and principles to boost customer discovery for your own product. I will also write about creating a channel for your product using inbound marketing.

I hope to see you on my new blogs, since I will put this blog on hold for a while.

If you’re interested, you might want to follow me on Twitter: @michiels and @inboundboard.

{ 0 comments }

Today I came across a test scenario where I wanted to check wether the style attribute on a div with id=”banner” would be filled with something.

In this application, we want to check for this because the user can manage a banner image in the admin and set the background of the div with it, but if the image is not set in the admin it should fall-back to an img tag.

For this we used capybara’s have_xpath to check for the div and the style attribute:

Then /^I should see the image just uploaded as an infographic$/ do
  visit root_path
  page.should have_xpath("//div[@id = 'banner' and contains(@style, 'background-image')]")
end

Do you have any other way of checking the attributes of html tags in a Cucumber test or are there other good ways to do this? What is your opinion? Otherwise I hope this will help you :)

{ 0 comments }

I’ve heard a lot of stuff about Chef by Opscode some time ago but never actually gave it a try. Chef is a bundle of software that allows you to configure and install your servers by coding, not by entering commands. I fiddled with it one time but it was really hard to set up.

Because we’re launching our new server infrastructure on a new bigger Amazon instance in a fe days, I thought I’d give it a try.

The main reason I was looking for something like Chef was automation. In the past I would install every server manually and I didn’t have some predefined bash scripts for setting up a server, installing the base system and preconfigure Rails, PHP apps and things like backups. Chef allows me to do that now.

Our new server is going to run various apps. Our own website, some WordPress websites and mainly Ruby on Rails apps. Because we run some business-critical apps for our clients the server setup should be clean and certainly not hacked together, and we need external backups to S3 and be able to add another server to the pool when usage gets bigger – which is going to happen.

When you have Chef installed, you probably want to run a Chef Server and a Chef Client. The Chef Server keeps all the state of the server configuration for the configuration and installation scripts. The Chef Client actually reads the configuration and runs the script.

The chef clients runs multiple recipes that configure your server. For example, a recipe downloads apache or nginx via apt-get when you’re on Ubuntu, but could install an RPM if you are on an rpm-based distribution. The recipe is the actual script, but you can also store configuration attributes and download urls with the recipes. These little bundles of recipes and other configuration are called cookbooks.

We currently have the following cookbooks in our Chef repository:

Screenshot of the directory lay-out of our Chef repostitory

Our Chef repository

Recipes can depend on other recipes from other cookbooks. For instance to install Phusion Passenger and nginx, I want to use the ruby_enterprise cookbook so it will first in stall the Phusion Ruby Enterprise Edition and then installes and configures nginx and passenger for it.

We use Scout App for monitoring the performance and usage of the instance and we use it so we receive warnings if something reaches critical numbers.

For Scout, I did not run the Scout agent as explained on their on website, but I created a recipe for it in the scout cookbook:

gem_package "scout" do
  action :install
end


gem_package "request-log-analyzer" do
  action :install
end

user "scout" do
  comment "Scout Agent User"
  home "/home/scout"
  supports :manage_home => true
end

execute "scout_first_run" do
  user "scout"
  command "scout #{node[:scout][:key]}"
  creates "/home/scout/.scout/client_history.yaml"
  cwd "/home/scout"
  returns 1
  action :run
end

cron "scout_run" do
  minute "*/5"
  command "scout #{node[:scout][:key]}"
end

What this recipe does it that it installs the gem “scout” using the gem_package Chef command. It then goes on to create a new system user for scout, run the scout agent for the first time and actually adds a cronjob to run it every 5 minutes.

You can see the code is quite clean and it doesn’t look like a hacked-together bash script and it doesn’t look as closed down as some kind of configuration database or .ini file. They are nice Ruby recipe’s for configuring stuff on your server.

You can see that I’m using the node[] variable a few times. The node variable is a Ruby hash of the current configuration the server (or node) is in that the client is being run. Using the web interface on the Chef server you can actually configure per-server configuration values. In our case, the Scout key would be different for every server.

You can do a l it more with these recipes like defining templates for files, default attributes, generating passwords but I’ll save that for another post.

The best thing about the recipes is that I can also communicate with the AWS API. The application cookbook you see there actually creates an EBS block storage devices and attaches it to the current node if it is not already created.

Because all state is saved in the Chef Server configuration database you can easily add more block storage devices or other external stuff just by running the Chef Client. The Chef client probes the server for all the current state the client is in and goes on upgrading all the new changes the recipes requested.

The status page in the Chef Server webapp

{ 0 comments }

Some downtime this morning

by Michiel on April 21, 2010 · 0 comments

in General Posts

Hi all,

I had some downtime today so I’m sorry if you could not access this blog to get help on all the topics I right about. Everything should be fixed now. There seemed to be an error with our hosting provider. I’m trying to see if it was something major or if it was just a minor glitch in the power or connectivity or something.

Anyways, back up now so enjoy!

Update: It seemed there was an administrative error with the supplier of my hosting provider. Will not happen again!

{ 0 comments }

I started using Heroku three weeks ago since @_micho from teambox.com recommended it to me. He told me they had a free app tier with some basic functionality and you can upgrade if you need more power or other functionality.

I’ve been testing it for deploying several development and staging apps the last two weeks and Everyday Feed already runs on it in a production-kind-of way. I’ve come to a conclusion: always deploy your first deployment on Heroku.

So, why is this?

  1. Because Heroku is an app-based deployment service instead of an instance or server-based deployment service you can focus on the application and making it work, without having to worry about server installations, best deployment settings, software etc. You deploy your app on Heroku so you can fix your app, and not waste time on fixing your server.
  2. Heroku is totally Git-based so it will force you have a good Git-workflow right away, from the start of your first deploy. One of the advantages of using Git is of course that your code is in version management and you can easily manage various feature sets and rollback to previous deployments, but it’ll also help you right away when you get more team members.
  3. Heroku forces you to configure all your things that run around your app, like cronjobs, sending email, doing queuing and caching. Because Heroku forces you to work in a very automated and modular way you’ll never mess up your app’s code with external things. This make sure you configure everything nicely in external files or in the Heroku admin panel so you never hardcode things in your code.
  4. Heroku is free. Well at least the first database package they have (up to 5MB). I like this from a business point-of-view because you can also scope what you spend on Heroku with your income of the app. I have a simpel rule with Everyday Feed: I will not upgrade Heroku until the application has some users or advertisers that are paying. This way I make sure people want to pay for the core functionality and add extra features from there, when I can buy more power at Heroku.

[click to continue…]

{ 0 comments }