Thursday, June 19, 2008

Rake + Cron = Goodness

Our new site does some crawler tasks that run periodically throughout the day. While in development I just kicked these off using an http request from my browser, but moving to something resembling alpha we needed to get them on a schedule. Since we're running on a Joyent OpenSolaris Accelerator we have access to old-school cron goodness for scheduling, but we needed access to our Rails application environment - simply creating a cron task to execute a .rb file wouldn't cut it.

Fortunately rake is there to save the day.

Step 1 - Create your rake file
Touch a new file called yourname.rake and put it in /yourapp/lib/tasks. I called mine 'update.rake'. Add the following:

namespace :update do
task(:say_hello => :environment) do
puts 'Hello, World!'
end
end

Putting the file in lib/tasks and using :environment makes the script seemingly magically aware of your rails environment, so you can use ActiveRecord and everything else in your application.

Step 2 - Execute and Test
Next navigate to your app's home directory and run using your environment:

rake RAILS_ENV=development update:say_hello

you should see...

Hello, World!

Step 3 - Schedule
Next set up your cron job as you would normally. With Joyent the "Schedule Cron Jobs" section of Webmin makes it a snap, but there are as many ways to use cron as decades since it was created. Set up the following command using the path to rake on your server (use "which rake" if you aren't sure) and your rails app.

cd /your/rails/app && /opt/local/bin/rake RAILS_ENV=development update:say_hello

Now you should be able to set up application-aware rails code which executes whenever you please.

Extra Credit
You can make your rake script more object-oriented by putting real Ruby methods in your rake script. Check it out!

namespace :update do

task(:say_hello => :environment) do

delegate_hello

end

def delegate_hello
puts 'Hello World!'
end

end

Saturday, June 14, 2008

Startup Hats and Combinations

In my last entry I alluded to the discrete hats that somebody needs to be wearing in any sort of web startup. Others have expressed a long list of roles, and just the other day on the Seattle Tech Startups email list someone inquired about how they could get into a Project Manager role on a startup, so it's clear there is some question over what is needed. So, here are the hats according to me, and the configurations I've seen work to cover the bases well.

Hats



Developer - Someone has to build the thing. You are generally much better off with MacGuyver than with "Wall Full of Certifications Guy", and absolutely avoid a programming theologian/idealist. They must be very fast, good at writing straightforward, readable code, use but not go overboard with object orientation, and generally be more proud of the site they create than the structure of the code they wrote.

People Skills - Evangelist, salesperson, press releaser, blogger, pitcher, glad-hander, copy-writer, PR strategist. The face and the voice of your company.

Computer Guy - Linux/Solaris Admin, caching strategist, cluster deployer, migration script writer, database maintainer, scaling planner. Someone who giggles when you say "sudo make me a sandwich".

Right Brain - Someone who knows their way around Photoshop. A user experience design pro - pixel pushing and clickstream, ideally with freehand ability for the logo. Color, font, and CSS person.

Product Specialist - Social networking sites can skip over this one, but many niche startups will have a unique skillset required for what they do. For us it's a Mathematician, but it's as specialized as your startup.

Combinations


Most startups won't start with five people one wearing each hat, nor is it maintainable for one person to wear all five - it's overwhelming. Natural combinations are between:

Right Brain - People Skills and Developer- Computer Guy

I've made the case previously that from an hours-of-work perspective that one founder wearing the developer hat isn't enough and I still think so... to me an ideal pair is:

1. Developer-Computer Guy-Product Specialist and 2. Developer-Right Brain-People Skills

Outsourcing



You periodically see MBAs (People Skills) who have "an idea" and try to get funding so they can outsource everything else. More power to them. In my opinion Developer and People Skills are integral and can't ever be totally outsourced.

Right Brain is the easiest to farm out... in my experience it's a gift your founders either have or they don't - you can study enough to fake it and get by, but inspired user experiences come from naturally talented professional designers. It's also relatively narrow-term. Once you have your UI and "experience arcs" defined, this hat is largely pixel pushing until your feature set expands.
Computer Guy is tricky. On the one hand getting set up and developing a plan to scale is very short term, but you want more than a contractor's phone number when your server says it's in "maintenance" mode at 3 am. Most good developers at least know their way around a unix box, which is enough to get started. I can't imagine a core founder who only brings the Computer Guy skill to the table for a web app, but I suppose it depends.

People Skills - A true passion for your product is the best PR skill there is. The debate over hiring a PR firm will be raging years from now, and I've never done it, so I can't say. But I do think it's important for one founder to be able to make friends and influence people, and I've yet to meet someone who could do that who wouldn't make a fine People Skills guy.

Outsourcing development is another eternal question... if you can use it to turn dollars into an earlier release date it's a lovely idea, just make sure that you actually can. If you don't have someone on staff who can review the code you're getting you will probably come to wish you did.

All that said, I don't know any perfect teams. Motivated, passionate people can move mountains, and often do a much better job at tasks they have no experience with than professional contractors would.

Thursday, June 12, 2008

Observations on Early Startup Life


Lately I've been reflecting on this fantastic job of mine, and if you'll pardon the solipsism I thought I would share some observations on what it is and isn't like.

I should preface with a little bit more than usual about what my job is... I am a full time startup co-founder building a not-quite-beta startup. I am lucky enough to be able to at least fake at wearing all the primary hats, so I do everything from programming to pixels to PR. I've been doing it and some small business contract work on the side full time for about nine months.

Founder Types

They say there are two kinds of founders, "builders" and "entrepreneurs". I have found this to be true. Builders think about problems and their instinct is to wonder what solutions could solve those problems in an elegant way... entrepreneurs think about problems and instinctively wonder what untapped markets could be opened by solving them. The best litmus test I have found is to ask "If you were wealthy (whatever number that means to you), would you still be doing this?" It isn't perfect; there are plenty of entrepreneurs for whom finding "angles" is an addiction, but builders would definitely be creating products if they didn't have to.

Bad Reasons

If you decide to create a startup because you want to "be your own boss", you're making a mistake. You'll always have people to answer to in some form or another, whether they're clients, investors, or customers. For general headache-factor, a decent boss beats any of them. Give me Voltaire's "enlightened despot" or even Edward James Olmos any day. You can't avoid dealing with people and their quirks, and in the end you probably wouldn't if you could.

If you create a startup because you want to "make your own hours" you're making an even bigger mistake. There are plenty of opportunities to work in your pajamas in 2008 and still be on someone's payroll. To do the startup thing right you are going to be working all the time. The biggest difference between a founder and a telecommuter is that the telecommuter gets to clock out at the end of the day, whereas the founder has "dinner break" before the late shift starts. The lines between "work" and "non-work" tend to blur. Additionally, I am most productive when I don't sleep in and prefer to work at a desk a lot of the time, so I'm in an office co-op called Giraffe Labs. Logistically speaking, the startup is an awful lot like a flexible corporate gig.

So what makes it such a great job? The fact that the things you create are your babies. I feel intense pride for the software I've had a major hand in the creation of. The hours are ridiculous, but the definition of work has changed completely. I'll still be "The Wantrepreneur" until I have a liquidity event, but whatever happens the experience has been a huge success... which I realize makes me a "builder".