Archive for January, 2013

Trying to Get Keep-Alives in Unicorn

Tuesday, January 8th, 2013

Ruby

Today I struggled trying to get the same keep-alive going in out production server, but because it's running Unicorn and not Thin, and Unicorn is not an event-driven server, it was a lot harder. To be fair, a lot of this had to do with the problems I was having with the deployment of software to the boxes. The Shop has a lot of progressive tools, but the deployment of packages is not among them. So there were several hours lost there.

But the real problem was figuring out how to integrate an EventMachine into the Unicorn server. Thankfully, I was able to find a simple way to do it:

  Thread.new { EventMachine.run }

So simple, but so completely non-obvious.

With that, it started working and I just continued to struggle with the fact that Unicorn doesn't expose a logger like Sinatra/Thin.

These are not the easy tools that folks make them out to be.

Google Chrome dev 25.0.1364.26 is Out

Tuesday, January 8th, 2013

This morning I noticed that Google Chrome dev was updated to 25.0.1364.26 with it's now typically terse release notes. It's loading fast and rendering just fine, so I'm not going to complain, but you'd think that an engineer at Google would have a little more pride in their work than these lame release non-notes. Kinda sad.

Nice Keep-Alive for Sinatra Apps

Monday, January 7th, 2013

Ruby

Today I've been working very hard to get this ruby app (Sinatra) to have a keep-alive with requests that take a very long time to complete. Typically, you might think this was a case for streaming the data, and in some cases, that's true. But in many of the cases I'm dealing with, the server has to marshall a lot of data, piece it together, and then format the output. It's really not ready until it's all ready. So I needed a simple keep-alive.

Back in a previous job, I used Tomcat and just had a thread that sent a space every 10 seconds to the client until I stopped it. I then put this in the rendering code, and all of a sudden, everyone got this keep-alive code, and no one had to worry about a thing. I know it's not going to be that easy this time, but it's not that far off.

First, we need to make sure that we're using the 'Thin' server in Sinatra. WEBrick doesn't support an event model, and so won't be starting an instance of EventMachine. This is thankfully pretty easy to do, just require 'thin', and backup will detect it and we're good to go:

  require 'thin'

Next, we need to put the keep-alive in the individual calls. This one, for instance, takes a while to complete:

  get "/call_list_spreadsheet/:dbname/:extag.tsv" do
    content_type('text/tab-separated-values')
    attachment("call_list-#{params[:dbname]}-#{params[:extag]}.tsv")
    stream do |out|
      timer = EventMachine.add_periodic_timer(10) do
        out.write("\0")
      end
      out.write(CallListTSV.new(params[:dbname], params[:extag]).render)
      timer.cancel
      out.flush
    end
  end

the key component here is that little bit in the middle:

      timer = EventMachine.add_periodic_timer(10) do
        out.write("\0")
      end

Simply put, that's going to send a NULL to the client every 10 sec. until the timer is cancelled. This works like a charm to do what I need. Amazingly so. I was really quite pleased.

All this is in a nice little gist.

Once Again, GitHub Totally Amazes Me!

Monday, January 7th, 2013

This morning I went to create a new Gist, and saw that GitHub has once again, upped the ante on the source control tools with a complete facelift on the Gist pages. This is really amazing. It now allows for tabs or spaces, and even allows for the size of the indentation. This is just superlatively cool!

Amazing facelift to Gists

I'm amazed that these guys are able to keep raising the bar. It's so unusual for me to see things that I love, and yet had no idea I felt I needed them. These changes are just more of the same from GitHub. What an amazing group of people.

Struggling With a Lot of Things Lately

Sunday, January 6th, 2013

This last week at home has been a real struggle for me. I'm trying to figure out why I'm working as hard as I am in a job with pretty much no bonus structure and co-workers that think that coming in at 8:00 am is too early. I'm not saying they are wrong, I'm wondering why I'm working as hard as I am if they are seen as OK?

There's similar stuff going on at home. I'm working harder than ever, but it appears to be a completely thankless job - even from those that should know better.

So the latest is that the project manager for the project at The Shop said that he had to have certain transparency features that he has now - when we move to the new demand system - that we've already moved to, by the way. He said that he needed two features that I an specifically told him he was not going to have if we moved forward with this project, and he said he was "OK" with that. I've come to learn that he's the one individual that I've talked to at work that consistently never really listens to me.

Oh, I don't think I'm singled out in that regard - I'm sure there are lots of peopler he doesn't listen to, but when I take a lot of time to lay things out clearly, and carefully, and he buys off on them, it's more than a little annoying to see him do a complete 180 when it's now deployed. It shouldn't be a surprise, but it's incredibly frustrating, and it's really gotten me thinking.

Like why do I even try? Why not just give him the crap he's asking for, and then when he gets it tell him he didn't listen to me, show him the emails, and then stare at him in the face. If he thinks he doesn't have to listen to me, maybe he doesn't? Who am I to say?

At the same time, I'm ready to quit. Of course I won't, but this is exactly what I hate most about the places I've been recently - crappy management. Really crappy management. If they want me to do something weird, or talk to this legacy system, or whatever, at least I can understand that reason and move on. But when the manager of the project is countermanding his own orders, then it means there's nothing I can count on at all. There's no reason to say anything, and in short, everything is a waste if time.

That's what's so frustrating. Feeling like I'm wasting my time. I hate that.

Anyway, tomorrow is the first day back, and I'm going to present my case, point out that he was told about these, and then let him pick. After he chooses wrongly, I'll just talk to my management (other management, this place is like Office Space) and tell them that this is the one thing I hate, and has caused me to leave other places. I'm not being mean, or nasty, but if they understand the total crap this is, I think they'll at least understand my position - even if they don't applaud my response to it.

They can't like wasting their time anymore than I like wasting mine.

I got a lot of anger towards a lot of people right now. Wanna just throw it all away, but I have to deal with these people, and that makes it very very hard.

Moving Forward with Low-Priority Work

Wednesday, January 2nd, 2013

Building Great Code

This evening I did a little work on a few low-priority tasks in the project I'm on. Normally, I wouldn't worry with stuff like this, but a nice guy in the group in Palo Alto really wanted this stuff added to the code, and so I took the time to finish the work I started several weeks ago that he needed.

Normally, I agree with the priorities we have. It keeps my work at a manageable level. But there are times - like this, that I feel kinda bad that I don't have a few more hours in the day/week/month to push a few tangential things forward a bit. Yeah, it's gotten me scolded in the past, but my argument this time is simple - I'm at home, I already did a lot of work for the day on the stuff that is meant to be my high priority, and it was after 5:00 pm.

Basically, I did it on my own time.

Thankfully, it wasn't that hard - took me a few hours, and now it's on a pull request into the main codebase and we should have something ready to test in a day or so. I feel like I've been a "nice guy" today. Makes me feel good.

Refactored the Closed Deal Code

Wednesday, January 2nd, 2013

Dark Magic Demand

Today I spent a good chunk of the day refactoring the clojure code with regards to the Closed Deals out of Salesforce. Specifically, after I got all the original work done, I realized that as it stood, I didn't have a change of working. Why? Because the deals would change over time. The moment a deal popped up, it's have a fill count of zero and then over time, it'd increase to some final value.

This means we'd have to have mutable database records, and that's totally against the immutable concept that my co-worker had for the entire clojure-based project. So to make it mutable would make it impossible to re-run the code for any point in time - and that's no good. So it meant that I needed to re-do the code and get it to work with closed deal sets and then compare the sets I load in from Salesforce to the sets available in the database.

It wasn't horrific, but it wasn't trivial. I'm getting better at clojure, and that's nice, but it's also the korma library and all the other supporting tools that I need to get up to speed on to really be productive. In the end, there were a few issues, and yet I was able to get them resolved pretty easily.

In the end, I was able to get the imports running again in UAT and that was a great feeling. It was (albeit tiny) progress for the day.