5

Here's what I'd like to do in concept:

"Hook" node.js to a particular Git repository so that I can make a request like /84de7e8d8ce33/foo and the server will (if necessary) check out commit 84de7e8d8ce33, start up another node.js on the files it just checked out, and pass "/foo" to that new server. Of course, the main server keeps track of which commits it already knows about.

Basically, I'm just trying to simplify our release process, so the same server that does the above Git magic will also serve an index.html-like file that consists almost entirely of

<script src="/84de7e8d8ce33/app.js"></script>

My questions:

  1. Just how bad an idea is this?
  2. Is there some prior art, some library or framework that already does this?
  3. Is there an alternative? Some way that I have a release branch, tell node.js what commit to use, and let it go.
  4. Is there some built-in way of keeping multiple commits "checked out" (or at least visible as ordinary files in some fashion) at the same time?

(I have a subsidiary question about how to communicate, from me, as the release manager, to the server the fact that 84de7e8d8ce33 is now the live version. Right now, I'm thinking, memcached, but I'm open to other suggestions.)

1
  • 1
    You might find Git.js, a Git implementation in JavaScript, useful for your task. Commented Aug 10, 2011 at 21:10

1 Answer 1

3

It doesn't sound like a bad idea at all. I would first try using https://github.com/libgit2/node-gitteh

Besides having a cute name, it

  • should be faster than shelling out to git
  • has a javascripty API

I would run it in a separate process from the web server, using node-redis and/or dnode to communicate.

Edit: I found the docs, listed at the bottom of the README. Not until after I looked at an example and played with it in the node repl, though! It's quite nice. I was able to poke around and get a blob out of my repo. Also it works on .git, not a working tree, so you might be able to have multiple possible commits without having multiple copies of the repo.

Sign up to request clarification or add additional context in comments.

3 Comments

I'm accepting this answer, but I do want to point out that saying "It doesn't sound crazy at all" to someone who hasn't said anything along the lines of "Does that sound crazy?" can made that someone a little bit nervous.
Oops. s/crazy/bad idea/. I didn't mean to mix them up. I think it's because I've misused and been around others who have misused the word crazy a lot. I'm glad not everybody takes the word so lightly!
A friend of mine arranged his honeymoon on a tiny Caribbean island. The last thing the travel agent said to him was, "And don't worry, there's no trouble with the electricity." No surprise, the power was out the whole week they were there. People tell me out of the blue "oh no, you're not crazy." and I start to think...

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.