OpenVZ howto addendum: Migrating your virtual machines to a new server

As I wrote some time ago, creating your own OpenVZ infrastructure is very easy, and it can save you a lot of money compared to the usual VPS providers. But it also has other advantages.

Hashtagify uses redis to store all its data in memory, which is great for performance, but… it requires a lot of RAM. So it happened that I almost finished my 24GB, right when I learned about a new great offer for a 32GB server which costs 33% less than my 24GB one. Moving to it means that I’m going to get back my 150€ of activation costs in just 5 months, while at the same time having 8GB more. Great!

This is why I bought a new server and decided to move all my virtual machines to it from the old one. It turned out to be quite easy, but I had to find the instructions in different places, so I’ll post here how I did it for both my future reference and for anybody else having the same problem.

First of all, you have to install OpenVZ: I did it just following my previous howto.

Then, you can migrate your machines. I thought I would need to back them up and then restore them in the new server, but I found out there is a more direct and much faster way to do it: The vzmigrate command.

To use it, you first need to enable password-less ssh login from the old server to the new one (this is because vzmigrate uses the ssh protocol to move the files). First, generate your public and private keys if you didn’t already:

ssh-keygen -t rsa

It is important that you create it with no passphrase. Then, move the public key to your new server, like this:

scp /root/.ssh/id_rsa.pub root@XX.XX.XX.XX:./id_rsa.pub

Now log into the new server and do

cd .ssh/
touch authorized_keys2
chmod 600 authorized_keys2
cat ../id_rsa.pub >> authorized_keys2
rm ../id_rsa.pub

After this, in the old server check that everything is ok with:

ssh -2 -v root@XX.XX.XX.XX

If everything is ok, you whould be logged in without being asked for a password. You can log out

exit

and start migrating your machines. For each machine, for example the one with id 101, you do:

vzmigrate -r no XX.XX.XX.XX 101

This will take a pretty long time, depending on how big the virtual machine and how fast the net between the two servers are. There is no progress indicator, but you can get an idea how it is proceeding by checking the original size of the machine and the size of the copied one, by using the command

du -hs /vz/private/101

on the old and the new server respectively (this of course only if you mapped the openvz data directory to /vz as shown in the original howto.

When the command finishes, the new machine is ready… but only if you could move the VM IP from the old to the new server. In my case that wasn’t possible, so I had to ask for new IPs on the new server. You can assign the new IP, and remove the old one, like this:

vzctl set 101 –ipadd NEW.NEW.NEW.NEW –save
vzctl set 101 –ipdel OLD.OLD.OLD.OLD –save

So, now you’re really good to go:

vzctl start 101

And that’s it!

Cheers

Posted in Hosting, Open Source, Technicalities | Leave a comment

Hashtags on Google Plus too!

As pointed out by Chris Messina, the “inventor of Twitter hashtags” (rather, the one who pushed for their adoption on Twitter, which is no little feat), Google just rolled out hashtags autocompleting on Google Plus, thus giving their official support for hashtags there.

This is very good news, because hashtags are a really easy way to tell what your posts are about. And because hashtagify.me could add Google Plus hashtags data too in the future… would you like that?

Posted in Hashtags, Roadmap | 6 Comments

Hashtagify Pro: Would you like it to be from Hashtagify, ltd?

The beta of Hashtagify Pro is going well, and I’m going to release it officially soon enough.

I have to decide if I should incorporate as Hashtagify Ltd. before launching: Would you trust Hashtagify Ltd. more than Daniele Mazzini? Please vote here: http://news.ycombinator.com/item?id=3403065

Posted in Uncategorized | 3 Comments

Hashtagify Pro private beta

Lately I’ve been hard at work on Hashtagify Pro, a new tool that lets you track a specific campaign or subject (not limited to hashtags) on Twitter and analyze which influencers are impacting it and how.

Today is a big day: We are ready to start a private beta!

You can go to pro.hashtagify.me and take a look at the new website, where you can also find a Demo/Tour that shows the kind of analysis you can do with Hashtagify Pro.

If what you see interests you, you can apply for a free beta account using the link in the home page. Beta accounts will be activated as soon as there are free resources on the server.

We’re also very interested in your feedback: Comments, glitches, ideas, suggestions. Hashtagify Pro is still in evolution and your suggestions now can have an important impact.

So, let us know what you think!

PS: Hashtagify Pro works best with a recent browser. IE only works with version 9.

Posted in About us, Features, Releases, Roadmap | Leave a comment

Update CSS rules with 5 lines of CoffeeScript

I recently (ie, today) had to find a way to update a CSS rule dynamically in javascript. jQuery, my library of choice, doesn’t offer this functionality – and I really wonder why – so I looked around a little and found how to do it with plain javascript.

As I’m actually using CoffeeScript, I decided to rewrite it in that language and make it a generic function; it could be useful to others, so, there you go:

@updateCSS = (selector, styles) ->
  for sheet in document.styleSheets
      for rule in sheet.cssRules || sheet.rules || []
        if rule.selectorText == selector
          for style, value of styles
            rule.style[style] = value

You can also find an usage example (and play with it yourself) on jsfiddle. Enjoy :)

Posted in Technicalities | 6 Comments

The European Tech Scene in Blogging

I’ve been too focused on my work on hashtagify pro lately – the first beta isn’t far, by the way – to notice it when it came out, but this article about the European tech blogging scene is very interesting.

The long and the short of it is that we in Europe should blog more in English, to make it easier to create a European tech community and a more interesting scene to report on. Incidentally, that’s why I started blogging in English for hashtagify, so I just have to agree. I’m also seeing more conversations in English between Europeans, eg on Google+, so I hope we’re headed in the right direction.

Writing in English isn’t as easy as I’d like it to be, but the good signals – both those cited in the article, and those which I can see for myself – make me even more resolute. Let’s all keep our efforts up.

Posted in Uncategorized | 1 Comment

Is the open source/internet singularity coming?

Many have heard about the idea, popularized by Ray Kurzweil, that a technological singularity is coming. In a nutshell, the idea is that as the power of computers is growing exponentially, at some point it will bring about an artificial intelligence that will overtake human intelligence, reinforce itself and change everything beyond any (human) imagination.

I personally don’t believe that the creation of an AI able to compete (let alone surpass) with human intelligence is near at all. But while working on my latest web project, I noticed just how easier it has become to create incredibly powerful and attractive new software than just a few years ago. And all this thanks to Open Source and the internet.

Increasingly, we see amazing new software libraries, frameworks, programming environments being released as (Free) Open Source on the internet. This makes it progressively easier for other people, even solo developers working from home in their free time, to create great software, and often give something back to the Open Source community.

Not just that; the internet is making it easier and easier to find the best new pieces of software, to get answers to the most difficult programming questions, to circulate ideas and to publish the end results of it all. And to bring this all to even the most isolated programmers, in the remotest parts of the world.

Isn’t this all it’s needed to create an exponential growth of software innovation? I guess it is. And I don’t know what this will bring about, but it is a fact that information technology is disrupting lots of industries, with consequences that are harder and harder to predict – as unfortunately the current economic crisis is showing.

I don’t know if this could be the real technological singularity, even without artificial intelligence in the mix, but it could come damn close.

Posted in Open Source, Opinions | 14 Comments

Javascript async testing tutorial: Jasmine + Rails 3.1 + Coffeescript

I recently wanted to create automated testing for coffeescript code in Rails 3.1, including some async (ajax) code. I had to dig around quite a lot, so I’m writing here what I ended up doing for future reference for myself and others who might need it.

There are many test frameworks for javascript, and the one I chose is Jasmine. Reason why: It is one of the two most used frameworks, and the other one is dependent on jQuery. I’m using jQuery in this project, but I’ll be able to use Jasmine for future projects without jQuery too, so I chose it – I also like its syntax.

You can integrate Jasmin in Rails 3.1 yourself just using the Jasmine gem, but to simplify things with Coffeescript I decided to use a specific gem for the latest version of Rails and its assets pipeline. I couldn’t really choose between test_track and jasminerice, which are both very young, so I went with the first one just based on intuition. Using the other one shouldn’t be very different.

So, I added to my gemfile:

gem "jasmine"

gem "test_track"

and installed the new gems with “bundle”

I then created a spec/javascripts and spec/javascripts/helpers folder in the project tree. As I wanted to be able to easily test jQuery, I downloaded jasmine-jquery.js from github and copied it into spec/javascripts/helpers.

At this point I created the following jasmine.js file om spec/javascripts:

// SUITE :: Jasmine
// SUITE MANIFEST :: spec/javascripts/jasmine.js
// TEST SRC DIR :: spec/javascripts
//
//= require helpers/jasmine-jquery
//
//= require JsonDataSpec

JsonDataSpec is the coffeescript spec file that I was going to create and that will be executed in the test. See the following example

spec/javascripts/JsonDataSpec.js.coffee:

describe "JsonData", ->
  it 'should should have the correct format', ->
    answer = null
    $.getJSON(
      "/controller/get_my_data/",
      (data) ->
        answer = data
    )

    waitsFor ->
      answer

    runs ->
      expect(typeof answer.string).toEqual('string')
      expect(typeof answer.number).toEqual('number')

The secret here is waitsFor -> answer, which will wait until the answer variable gets a non null value – that is, when the ajax call is complete. Only after that the actual test is run.

Last thing, I configured the test_track engine adding this code to routes.rb:

mount TestTrack::Engine => "test"

And that’s it! To use my tests, I just run the server using rails s and access the tests opening http://localhost:3000/test/jasmine in the browser. Smooth and easy.

Happy testing!

Posted in Technicalities | 8 Comments

Bootstrapping hashtagify pro: How I doubled my workweek productivity

Creating a startup while working a full time job has its pros and cons. Among the pros, you don’t have to use a lot of your time minding your investors (or looking for them), and you can devote your energies to just make the best possible product. Among the cons, progress is slower and it is very difficult to be productive on workdays, when you already spend 8 hours or more on your day job.

But a week ago I read a comment on HN (edit: thanks to raju in the comments for pointing me to the exact link) that inspired me to rethink how I’m organizing myself , and with one simple change I doubled my productivity on workdays. How? Instead of working on hashtagify at nights, after getting home from my day job, I’m starting my day two hours earlier, and doing 2 hours of programming in the morning, before going to work.

I’m usually a night person, and have always been very productive at nights, since when I was just a student. But after eight hours of work, it is difficult to have that kind of focus that you need to program, and the two (or two and a half) hours in the morning have been much more productive than the equivalent time in the evening.

After coming home I still do some lighter work, and don’t go to bed without having scheduled a task to do the next morning; this way when I wake up I don’t have to think what to do and I can be immediately productive.

So, the bottom line is that work on hashtagify pro is proceeding very well: now I’m making as much progress during the workweek as I usually make during weekends, while before I only made major progress outside workdays. This means that soon enough I’ll be able to release the first beta. Stay tuned!

Posted in Roadmap, Startup | 45 Comments

Evaluating a Twitter Campaign

If you’re doing a marketing campaign on Twitter, how can you measure its real impact? And, specifically, how can you evaluate the individual contribution of single campaign participants?

This is something that has been asked to us, and we think we’ve found an interesting solution to visually show this information by leveraging the hashtagify technology. So, if you’re interested in this kind of analysis, stay tuned. And, if you have specific suggestions or requests related to this, don’t hesitate to contact me writing to @hashtagify . First come, first served…

Be seeing you!

Posted in Features, Roadmap | 4 Comments