3

On local development, you start a redis server using the "redis-server" command. However when I deploy the project to nodejitsu (using jitsu deploy), there isn't an interface to run this command, and launching the deployed app gives the following error:

Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED

How do I startup redis on a nodejitsu server? Is this enabled by default, or is there some config I have to change to get this working? Searched around but couldnt find any clues on this at all, is there something obvious I am missing out? Would appreciate any help at all.

soupasouniq
  • 193
  • 1
  • 9
  • Not sure it this matters, but I'm using the trial (free) nodejitsu servers. Is redis not supported on the trial servers? – soupasouniq Aug 10 '12 at 15:55
  • 1
    This kind of question could probably be answered faster if asked to nodejitsu themselves. You can jump on their IRC server #nodejitsu on freenode, or even sending an email will probably get a quick reply. – travis Aug 10 '12 at 16:01

2 Answers2

10

Yupp you guys are right - irc channel found the right people instantly.

So the answer from @AvianFlu is that nodejitsu doesn't host databases. However you can create couch, redis or mongo database instances with:

jitsu databases create <database type> <database name>

That will create databases hosted on eg. RedisToGo, CouchIris, or MongoHQ that you can use with your nodejitsu app. More details on DB connection - https://github.com/nodejitsu/handbook/#databases

If you are using the trial servers you won't be able to create databases (the small memory allocated makes it unfeasible to run the database on the same server), however you can still connect to your existing Redis/Couch/Mongo DB using the following code:

// Given this Redis conection string: 
// "redis://myDb:1234c6607579e81ff116374dc0cc4321@abc.redistogo.com:10108/"
// you can connect to your redistogo instance like so:

var client = redis.createClient(10108, 'abc.redistogo.com');
client.auth("1234c6607579e81ff116374dc0cc4321", function(err) {
  if (err) {
    throw err;
  }
});
client.on('ready', function () { // without this part, redis connection will fail
  // do stuff with your redis
});

@blakmatrix from nodejitsu replied my ticket with an excellent template for database connection, using an external config file. Super handy for multi-environments. https://github.com/nodeapps/boilerplates/tree/databases/helloredis

I can confirm that this works, even with a trial nodejitsu server and redistogo instance. Awesome.

soupasouniq
  • 193
  • 1
  • 9
  • More followup - Farrin Reid from nodejitsu support responded to my email with this awesome boilerplate for redis connectivity with nodejitsu - https://github.com/nodeapps/boilerplates/tree/databases/helloredis – soupasouniq Aug 11 '12 at 04:55
  • This all looks correct to me. If the handbook's wrong, I highly encourage you to make a github issue on the project so we can follow up on fixing it. :) Edit: I work for nodejitsu. – Josh Holbrook Aug 11 '12 at 05:15
  • Sure, I've created the issue for the handbook. Hope it can be expanded further for newbies. Great start nevertheless! – soupasouniq Aug 11 '12 at 13:58
2

Have you tried the jitsu databases command? Have you actively set any configurations for redis?

FYI: the Nodejitsu platform is very new. The public beta announcement was one month ago. There are probably a few hundred people using the nodejitsu product right now.

Your best bet here is to go directly to the source. They have a IRC channel on freenode: #nodejitsu, they also publish their e-mail on their support page.

If you plan to use this product, I strongly suggest getting on IRC. This is likely just the first of several hurdles you will have to work through.

Gates VP
  • 44,957
  • 11
  • 105
  • 108
  • 1
    +1 for irc. The nodejitsu staff are awesome guys and very helpful. – travis Aug 10 '12 at 16:17
  • Not sure if its cos im using the trial servers, but I can't create database instances - I get the error "Database could not be created". But locally I can connect to a RedisToGo instance fine, just not on the nodejitsu server. – soupasouniq Aug 10 '12 at 18:55
  • Just wanna followup with my findings - trial servers wont allow database creation. However you can still connect to your existing redistogo instances fine. See the updated answer for some helpful links from the friendly nodejitsu staff. – soupasouniq Aug 11 '12 at 13:59