HI IM RAILS I CAN HAZ MAGIC?

Again, why I hate all you fucking Ruby developers

I have a serious issue with Ruby magic.. no, wait, Rails magic… hmm, well no, maybe magic within the funky “sub-framework” I use?

Oh FUCKIN’ A, I don’t know. There’s a project I work on and it uses Rails. And it’s using an unnamed and incredibly shitty “sub-framework” (referred to henceforth as “Cyclops”) that forces us to use very specific gems whether we like it or not. In some cases the gems are cool, and in some cases they are the fucking devil himself. Continue reading “HI IM RAILS I CAN HAZ MAGIC?”

Dependency injection by any other name… still means you’re an idiot

Summary for those who don’t want to read yet another angry nerd rant

Dependency Injection is still Dependency Injection even if you use an approach that’s specific to Ruby 2.1 and decide to call it “Interception Injection”. Just like incompetent developers are still incompetent even if they start inventing fake patterns. Continue reading “Dependency injection by any other name… still means you’re an idiot”

Phusion Passenger – first impressions

Okay, as I recently mentioned, I’m tired of Mongrel for my Rails apps, so I’m going with Phusion Passenger.

The install was actually tremendously more difficult than they claimed, but I attribute that to my own lack of smarts. I am running on Debian, and installed ruby via the source, but had another version of ruby I’d installed via apt-get (it’s over two years old, hence my desire to install from source), and libopenssl-ruby also installed via apt-get. Somehow or another the ruby I installed from source didn’t pick up openssl support, but debian thought it was there, so when Phusion Passenger’s install told me Just type ‘apt-get install libopenssl-ruby’, I got frustrated fast…. I removed the packages and reinstalled ruby from source and all seems to be well now.

Another minor issue, and one I still don’t fully get, is that while Passenger is supposedly running as my main user, it can’t seem to read things that aren’t world-readable, even if I am the file’s owner! A few permissions tweaks (chmod -R 755 app_dir did the trick, but I’m not sure it’s the best idea) fixed this, but it was still a small point of confusion.

The really interesting issue with Phusion Passenger is that if you’re security-minded like I am, it does not work. My base Apache config includes this:

# Tighten access to the file system.
<Directory />
  # Forbid default access to file system locations
  Order Deny,Allow
  Deny from all
  Options -Indexes
</Directory>

Well, I’m a dummy, so I don’t realize why my Passenger-driven apps are “running”, but unable to access their javascripts, style sheets, images, etc. After a long while of searching, I found that the errors were happening because my default behavior was to disallow everything from being viewed. The really bad part here? It’s clearly spelled out in the troubleshooting section of their guide….

Now, in a normal Rails app, the Rails code handles static files, so you can keep your blindingly-high security in place. But Passenger is meant to be speedy, and letting Apache just serve static content directly is way faster than letting Rails do it.

So to fix this, one just has to say that the given app’s directory is allowed to be viewed:

<Directory /path/to/rails/app/public>
  Options FollowSymLinks
  AllowOverride None
  Order allow,deny
  Allow from all
</Directory>

The following of symlinks and AllowOverride settings are of course a matter of personal preference and security, but you must have the other two lines to let Apache server your static content!


Okay, I’ve had things running for a few hours now, and I’m having a few weird issues. One time when I restarted apache, Passenger simply didn’t start up for some weird reason. A new Rails app I built kept thinking it had bad permissions – I reset the whole dir tree to 777, then 755, then all was well again for no obvious reason. (Yes, I had already set it to 755. I think. Maybe.)


So aside from these issues (which are hopefully just due to my almost nonexistent linux admin experience), so far I’m liking Passenger. I have no idea how it would handle a traffic spike or if it has issues with rarely-used apps, but its Rails-centric approach makes it much nicer for a dummy like me to use. Configuration is a breeze, it auto-spawns and auto-destroys Rails processes as necessary, keeping me from needing to manage memory, it spawns the Rails framework separately from the app, allowing a huge memory savings on multiple apps that use the same Rails version, and it has a really helpful memory stat tool to see how much my apps are really hurting things.

Only the coming months will tell if it’s as solid as Mongrel usually was, but even if it’s only as good (i.e., crashes for no obvious reasons once in a while), I’m sticking with it for its nice configuration options.

A new day, a new blogging app

Typo seems cool to us Ruby on Rails jerks. Because it’s Ruby on Rails. It has sexy live searching. Um… and like… did I mention it’s Ruby on Rails?

So… yeah. After the thing sucking time and again, and eating too much memory and having funny stability problems, I’ve given up. I have enough annoyances with Ruby on Rails apps (I truly hope mod_rails helps here – stay tuned for my upcoming first impressions) that I wrote myself – no need to make things worse with badly-built open source.

So here I am on WordPress. I’m willing to bet it’s just another badly-build open source app. The difference, though, is it’s been around the block, and seems to have some stability under the hood. It wasn’t written with the “do what’s cool right now!” approach – it has been more geared toward functionality. So as much as I despise PHP, I can’t deny that this app is much nicer to deal with than Typo ever was. Even the conversion of my old articles was about a 10 minute process, thanks to Will Bridges. And with some minor tweaks, I now have a (hopefully) nicer URL structure.

Yeah, I’ll lose some SEO in the mean time – major site change, loss of something like 50 old URLs, but hell, it’s time for something that isn’t a headache.

I’m sick of Mongrel

I’ve been running my Rails apps (this blog as well as Bloodsport Colosseum) via mod_proxy and mongrel. Run a mongrel server at a given port, tell Apache to redirect a given virtual host to said port. Takes a lot more knowledge than a noob like me has, so even though it’s better than dealing with fastcgi + Apache or lighttpd, it’s still annoying.

Once I got it up and running, however, I figured it was good enough – everything worked, so all was well. Until I had apps that weren’t hit very often. Bloodsport Colosseum is hit pretty regularly, and this blog seems to get pinged by random sources all the time, so both worked well. But my now-deceased fanmail app (granted it was really far too simple to warrant the RoR framework, but that’s a whole different story) was hit maybe every few days.

Mongrel did not like this for some reason. It seems that any app that isn’t getting regular hits just dies after a while. I read somewhere that it was mysql’s fault, closing the socket or something like that. Interestingly, my PHP apps that use mysql don’t have that problem, and on my last server (privately hosted by a friend and using fastcgi), my Rails apps didn’t have that problem.

Okay, fanmail app was kind of unnecessary anyway – I can just put my smart and not at all fat fan’s letters of praise on the main site, run via PHP, and that’ll be good enough.

Then I for once blogged a popular topic – the Network Solutions “scandal”. I was actually #3 on google for the search “network solutions domain name front running” for a little while. But the next day when I checked how things were going, I noticed that mongrel was “running”, but not responding, much like what I saw when an app wasn’t hit regularly. The process list would show a mongrel process using almost no memory (very atypical of a Rails app), and Apache would give an error that the proxying couldn’t happen. So the one time I’m really getting visitors (About 100x normal traffic levels for my shitty blog), within about an hour mongrel had decided it had enough.

I don’t believe mongrel can’t handle large traffic loads, I just think my lack of skills combined with mongrel’s funky behavior problems caused issues.

All in all, I’m tired of that – Mongrel keeps misbehaving, and I’m DONE. Time for something new. I’m trying out Phusion Passenger tonight and we’ll see how it goes.