Deploying SQLite to Production w/ Capistrano

This weekend we rolled the innagural deploy of our top secret new rails app to production. We are currently using Rails 2.1, SQLite and nginx proxying to Mongrel. Why bother with Apache (ever) and MySQL before you have to? Additionally we’re on a 256MB slice from Slicehost which is already serving an FB app, so I’d really rather not have the overhead of heavy tools for light applications.

I think I’m a fan of SQLite even though I just started using it. As they say on their site:

The basic rule of thumb for when it is appropriate to use SQLite is
this:  Use SQLite in situations where simplicity of administration,
implementation, and maintenance are more important than the countless
complex features that enterprise database engines provide.
As it turns out, situations where simplicity is the better choice
are more common than many people realize.
...
SQLite usually will work great as the database engine for low to
medium traffic websites (which is to say, 99.9% of all websites).

I’m 99.9% of all websites! And simplicity is important to me, I’m configuring enough already; plus I should probably coding some features or something too. And even if scaling does become an issue, I’d first set up memcached, then analyze and optimize my db tables, then upgrade to a fattier slice, then upgrade to an even fattier slice, then consider a more “enterprisey” database solution: multiple servers and jet-packs for the queries.

Meanwhile, I encountered a “problem” with deploying SQLite to production via Capistrano. This “problem” basicly stemmed from monumental laziness and not reading (or configuring) the default database.yml file. Here’s the thing: on development SQLite works great because you keep updating and committing in your same local directory with your same DB file. In deployment however you usually check out a whole new copy of your app, update some symlinks, and blast off into the night. By default this creates a new SQLite db, and doesn’t include the migrations (they were applied to the old copy). I actually started searching google for the answer to this “problem”, thinking about changing my deploy.rb to update a symlink to the SQLite file… but then it was so much easier to:

production:
  adapter: sqlite3
  database: /absolute/path_to_db/on_server/production.sqlite3 # instead of db/production.sqlite3
  timeout: 5000

I’m actually almost embarrased to post this “solution” but maybe some wayward youth like myself will find it and save some trouble.

Pre-development status

Now that this project is about to start taking flight I decided I should start getting in the habit of posting what’s up in the development world. Eventually we may want to look back at these times and laugh at the ridiculous ideas we thought could pull off. Apparently I’m one of the main developers so I should have a pretty good idea what’s going on.

So far the game involves:

  • Characters interacting with each other
  • Characters building and growing things
  • All browser based with JS/Ruby on Rails
  • Characters can definitely have pets (most important game aspect so far)

That’s the gist of what we know so far. So what have we done so far? Pretty much nothing. But the discussion and spec phase of what we’ll accomplish is very much alive and well. I think this development chatlog really sums up the point of the game and our progress:

Yahivin
it's all pvp all the time
papashaft
I thought there were creatures too?
Yahivin
probably, they might be players
papashaft
what if you find a bear in the wilderness though?
Yahivin
what if you were a bear in the wilderness?!?!
papashaft
then that would rock

Boomtime Development Log – Episode 1

 me:  yo
 pappashaft:  hey
 me:  did you get that console thing going?
 pappashaft:  naw I just got home from basketball
I don't think I'll have time tonight
I have to make dinner and then watch from g's to gents
 me:  what the hell are you talking about?
 pappashaft:  haha
what the hell are YOU talking about?
 me:  touche
 Sent at 8:57 PM on Tuesday
 pappashaft:  we shoudl discuss goals and timelines and features at some point
 Sent at 8:58 PM on Tuesday
 me:  yes
do you read my blog?
 pappashaft:  perhaps tomorrow, I should have more time then
you have a blog?

Hey Raccoon! Stop stealing my fruit!

Dungeon Farmer has been moving along. It now supports two (2!) kinds of plants, so basically any number. That’s the thing about programming, you can either do something once, or any number of times. In addition to the new plant, there have been highlighting improvements, raccoon metabolism balance changes, basically the whole eight yards.

Now comes the time where I contemplate turning Dungeon Farmer into a product. Ugh… Listen to that, product. The only thing that I’m actively turning into product is that burrito I ate for lunch. I guess that’s the dream of the amateur, to create something idealistic, yet appealing; enough so that your user(s) can support you enough to buy a burrito.

So this is a call to action to my reader. Find my user and get his or her input. What can I do to make Dungeon Farmer appealing enough to encourage you to purchase me a burrito? Or a pizza, pizza is good too.

Ruby Weekend #2 – Dungeon Farmer

I recently participated in the RubyGame forums Ruby Weekend #2 game programming competition. I feel it turned out pretty well, but judge for yourself. I was pretty rushed during the weekend with other commitments so I didn’t keep a dev blog… next time. Also this blog was fallow until recently. This competition has spurred me to getting my web shizzy together.

McGriff Sez, Real User Testimonial

Bark back against crime!

Have you ever had the perfect message, but then not had the perfect dog to bark it? Well now you have the dog at least. Hear what real users are saying about McGriff Sez!

DW: yo did you get my barkblast? cobrien: ya I didnt know what that was so I ignored it

DW: did you get my barkblast?

l77: huh? what’s that?
DW: it’s a message on Facebook
a dog barks it
l77: oohh
i’ll check
i haven’t check facebook in a while

DWdid you get my barkblast?

kbw: what?
DW: on Facebook
kbw: i don’t know what that is
DW: you should check it out

so did you get it? kbw has left the chat

It all started in early 1995 when an episode of a famous TV show was on TV. The dream was an Internet in every PC and a barking dog messenger service in every Internet. The rest, as they say, is a long story…

Air Pressure Simulation

Here’s some images of the beginning stages of an atmospheric physics program. It uses the ideal gas law to determine the flow of molecules from high pressure areas to low pressure areas. It still needs tweaking to get a less turbulent dispersion; currently the pressure swings are around 5 kPa which is quite a lot compared to how real air mixes on a calm day.

1500ºK - 11500ºK - 21500ºK - 31500ºK - 4

This begins with randomly assigned temperatures from 0 – 3000 ºK for each cell, then lets the pressure naturally disperse them. Each cell begins with the same amount of molecules (134 moles) and occupies 3 cubic meters.

275ºK -1275ºK -2275ºK -3275ºK -4275ºK -5275ºK -6275ºK -8275ºK -10

Here is another selection, with starting temperatures from  0-550 ºK.

The eventual goal of this physics engine is to get a more realistic physical model for games similar to Dwarf Fortress. It will expand to cover liquids, combustion, state changes in matter, etc. The model is based on cellular automata so each cell only needs to check its neighbors.