Skip to content

Commit 0cc637c

Browse files
committed
heroku compatibility
port env var added app.json formatting free dyno
1 parent 78c6ffc commit 0cc637c

4 files changed

Lines changed: 33 additions & 4 deletions

File tree

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
# chat-example
22

3-
This is the source code for a very simple chat example used for
4-
the [Getting Started](http://socket.io/get-started/chat/) guide
3+
This is the source code for a very simple chat example used for
4+
the [Getting Started](http://socket.io/get-started/chat/) guide
55
of the Socket.IO website.
66

77
Please refer to it to learn how to run this application.
8+
9+
You can also spin up a free Heroku dyno to test it out:
10+
11+
[![Deploy](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy?template=https://github.com/guille/chat-example)

app.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"name": "Socket-Chat-Example",
3+
"description": "my first socket.io app",
4+
"website": "https://github.com/guille/chat-example",
5+
"repository": "https://github.com/guille/chat-example",
6+
"logo": "https://node-js-sample.herokuapp.com/node.svg",
7+
"success_url": "/",
8+
"keywords": [
9+
"node",
10+
"express",
11+
"socket.io",
12+
"realtime",
13+
"websocket"
14+
],
15+
"scripts": {
16+
},
17+
"addons": [
18+
],
19+
"env": {
20+
"BUILDPACK_URL": "https://github.com/heroku/heroku-buildpack-nodejs"
21+
}
22+
}

index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ io.on('connection', function(socket){
1212
});
1313
});
1414

15-
http.listen(3000, function(){
16-
console.log('listening on *:3000');
15+
http.listen(process.env.PORT || 3000, function(){
16+
console.log('listening on *:' + http.address().port);
1717
});

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@
55
"dependencies": {
66
"express": "4.3.1",
77
"socket.io": "1.0.2"
8+
},
9+
"scripts": {
10+
"start": "node index.js"
811
}
912
}

0 commit comments

Comments
 (0)