forked from jnummelin/node-redis
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
18 lines (15 loc) · 749 Bytes
/
Copy pathmain.js
File metadata and controls
18 lines (15 loc) · 749 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
var http = require('http');
var port = process.env.PORT || 8080; // use value from environment variable or 8080 if not set
var redisHost = 'redis'
var redisPort = 6379
console.log("Connecting to Redis@" + redisHost + ":" + redisPort);
var redis = require('redis');
var r = redis.createClient(redisPort, redisHost); //creates a new client
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/plain'});
r.incr('counter', function(err, reply) {
res.write('Hello World, I am v3 of the app! I have been invoked ' + reply + ' times! (This includes my predecessors also :D)\n');
res.end();
});
}).listen(port);
console.log('The server is running! Listening connections at port ' + port);