Skip to content

Commit 62b2581

Browse files
committed
Merge pull request buddycloud#190 from buddycloud/develop
Merge 'develop' into 'master'
2 parents 4c6e342 + 0665740 commit 62b2581

26 files changed

+278
-78
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
node_modules/
22
config.js
3+
!contrib/docker/config.js
34
.project
45
.settings
56
.DS_Store
7+
public/scripts/buddycloud.js
8+
npm-debug.log

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ before_install:
55
# https://github.com/travis-ci/travis-cookbooks/issues/155
66
- sudo rm -rf /dev/shm
77
- sudo ln -s /run/shm /dev/shm
8-
before_script:
8+
- npm install -g npm@~1.4.6
99
- npm install -g grunt-cli
1010
language: node_js
1111
node_js:

Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
################################################################################
2+
# Build a dockerfile for buddycloud-http-api
3+
# Based on ubuntu
4+
################################################################################
5+
6+
FROM dockerfile/nodejs
7+
8+
MAINTAINER Lloyd Watkin <lloyd@evilprofessor.co.uk>
9+
10+
EXPOSE 9123
11+
12+
RUN apt-get update
13+
RUN apt-get upgrade -y
14+
RUN apt-get install -y --no-install-recommends git git-core libicu-dev libexpat-dev build-essential libssl-dev build-essential g++
15+
16+
RUN git clone https://github.com/buddycloud/buddycloud-http-api.git api-server
17+
RUN cd api-server && git checkout develop
18+
RUN cd api-server && npm i . && cp contrib/docker/config.js .
19+
ADD contrib/docker/start.sh /data/
20+
21+
RUN chmod +x start.sh
22+
CMD ./start.sh

README-developers.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -72,33 +72,35 @@ As an example, the following snippet tells the server to listen on port
7272
};
7373

7474
exports.testing = {
75-
post: 3001,
75+
port: 3001,
7676
7777
}
7878

7979
The following configuration options are supported:
8080

8181
- **debug** (Optional): If true, the API server includes exception traces in
82-
"Internal Server Error" responses.
83-
- **port** (Required): The port on which the server listens for HTTP requests.
82+
"Internal Server Error" responses
83+
- **port** (Required): The port on which the server listens for HTTP requests
8484
- **xmppDomain** (Required): The XMPP domain to which the server belongs. This
85-
defines the XMPP server used for authentication and presence.
85+
defines the XMPP server used for authentication and presence
8686
- **xmppHost** (Optional): The hostname of the proxied XMPP server. This is
8787
only needed if the hostname and port cannot be resolved from the *xmppDomain*
88-
via DNS service discovery.
89-
- **xmppPort** (Optional): The proxied XMPP server's port. See above.
88+
via DNS service discovery
89+
- **xmppPort** (Optional): The proxied XMPP server's port. See above
9090
- **xmppAnonymousDomain** (Optional): The XMPP domain used for anonymous
91-
sessions. If omitted, *xmppDomain* is assumed to handle this case.
91+
sessions. If omitted, *xmppDomain* is assumed to handle this case
9292
- **xmppAnonymousHost** (Optional): Like *xmppHost*, but for
93-
*xmppAnonymousDomain*.
93+
*xmppAnonymousDomain*
9494
- **xmppAnonymousPort** (Optional): Like *xmppPort*, but for
95-
*xmppAnonymousDomain*.
96-
- **xmppDomain** (Required): The channel server's component domain.
95+
*xmppAnonymousDomain*
96+
- **xmppDomain** (Required): The channel server's component domain
9797
- **requestExpirationTime** (Optional): Number of seconds to wait for
98-
the response to an XMPP request. The default is 60.
98+
the response to an XMPP request. The default is 60
9999
- **sessionExpirationTime** (Optional): Number of seconds before a proxied
100-
XMPP session expires. By default, this is 600 (10 minutes).
100+
XMPP session expires. By default, this is 600 (10 minutes)
101101
- **https** (Optional): If true, the server communicates exclusively via
102-
HTTPS. *httpsCert* and *httpsKey* must be specified in this case.
103-
- **httpsCert** (Optional): The SSL certificate to use if **https** is defined.
104-
- **httpsKey** (Optional): The SSL private key to use if **https** is defined.
102+
HTTPS. *httpsCert* and *httpsKey* must be specified in this case
103+
- **httpsCert** (Optional): The SSL certificate to use if **https** is defined
104+
- **httpsKey** (Optional): The SSL private key to use if **https** is defined
105+
- **mediaProxyPrefix** (Optional, default __media_proxy__): The media proxy URL prefix. All URLs beyond this point are proxied to the media server without modification
106+
- **disableWebsocket**: Do not deploy the realtime/websocket endpoint

README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,36 @@ Build status of the develop branch
1515

1616
Install documentation is at https://buddycloud.org/wiki/Install
1717

18+
## Realtime connection
19+
20+
A websocket (using the [xmpp-ftw](https://xmpp-ftw.jit.su) interface can be found at __$server/scripts/buddycloud.js__. This exposes a global object called *Buddycloud*
21+
which you can instantiate to give you a websocket connection.
22+
23+
Please see [buddycloud.com](http://www.buddycloud.com) for more information on using this connection.
24+
25+
## Docker
26+
27+
There is a docker image available for the API server. Configuration is currently passed via environment variables:
28+
29+
| Configuration | Example | Description | Required or default |
30+
|:----------------------: |:------------------------: |:---------------------------------------------------------------------------------------------------: |:-------------------: |
31+
| XMPP_DOMAIN | buddycloud.org | The XMPP domain for your server ||
32+
| XMPP_HOST | 192.168.0.55 | The hostname or IP of your XMPP server ||
33+
| CHANNEL_COMPONENT | channels.buddycloud.org | The channel server component address ||
34+
| ANONYMOUS_COMPONENT | anon.buddycloud.org | An 'anonymous' component which can be used for open nodes | null |
35+
| MEDIA_ENDPOINT | http://192.168.0.56:9000 | The endpoint for a [media server](https://github.com/buddycloud/buddycloud-media-server) | null |
36+
| PUSHER_COMPONENT | pusher.buddycloud.org | The location of a [pusher component](https://github.com/buddycloud/buddycloud-pusher) | null |
37+
| FRIENDFINDER_COMPONENT | finder.buddycloud.org | The location of a [friend finder component](https://github.com/buddycloud/buddycloud-friend-finder) | null |
38+
| SEARCH_COMPONENT | search.buddycloud.org | The location of a [search component](https://github.com/buddycloud/channel-directory) | null |
39+
| DISABLE_WEBSOCKET | 0 | Whether to disable the [XMPP-FTW](https://xmpp-ftw.jit.su) endpoint | false |
40+
| DEBUG | 1 | Whether to write additional debug to the logs | false |
41+
42+
Then simply launch the API server with the required environment variables as follows:
43+
44+
```bash
45+
docker run -d -p 9123:9123 -e ..... buddycloud/api-server
46+
```
47+
1848
## Issues
1949

2050
Please log any issues at https://github.com/buddycloud/buddycloud-http-api/issues

config.js.example

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
exports._ = {
2020
// This is the port that your webserver's reverse proxy will forward requests to
2121
port: 9123,
22+
23+
// Whether to disable the xmpp-ftw endpoint
24+
disableWebsocket: false
2225
};
2326

2427
// Production settings
@@ -54,6 +57,18 @@ exports.production = {
5457
// required to enable buddycloud support for existing users on your xmpp server
5558
// createUserOnSessionCreation: true,
5659

60+
// log transport (file | console)
61+
logTransport: 'file',
62+
63+
// log file (only applies for file transport)
64+
logFile: 'log',
65+
66+
// log level
67+
logLevel: 'debug',
68+
69+
// log format (use json or not)
70+
logUseJson: false,
71+
5772
// pushpin and/or fanout.io is used for sending realtime data to clients
5873
// gripProxies: [
5974
// // pushpin

contrib/buddycloud-http-init

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ SCRIPTNAME=/etc/init.d/$NAME
3030
LOGDIR=/var/log/buddycloud-http-api
3131
LOGFILE="$LOGDIR/buddycloud-http-api.log"
3232

33-
# Exit if the package is not installed
33+
# Check if the node is installed, retry with nodejs, then give up
34+
[ -x "$DAEMON" ] || DAEMON=/usr/bin/nodejs
3435
[ -x "$DAEMON" ] || exit 1
3536

3637
# Read configuration variable file if it is present

contrib/docker/config.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
exports._ = {
2+
// This is the port that your webserver's reverse proxy will forward requests to
3+
port: 9123,
4+
};
5+
6+
if (!process.env.XMPP_DOMAIN) {
7+
throw new Error('Missing XMPP domain')
8+
}
9+
if (!process.env.XMPP_HOST) {
10+
throw new Error('Missing XMPP host')
11+
}
12+
if (!process.env.CHANNEL_COMPONENT) {
13+
throw new Error('Missing channel server component')
14+
}
15+
16+
// Production settings
17+
exports.production = {
18+
debug: process.env.DEBUG || false,
19+
xmppDomain: process.env.XMPP_DOMAIN,
20+
xmppHost: process.env.XMPP_HOST,
21+
xmppAnonymousDomain: process.env.ANONYMOUS_COMPONENT,
22+
channelDomain: process.env.CHANNEL_COMPONENT,
23+
pusherComponent: process.env.PUSHER_COMPONENT,
24+
friendFinderComponent: process.env.FRIENDFINDER_COMPONENT,
25+
searchComponent: process.env.SEARCH_COMPONENT,
26+
homeMediaRoot: process.env.MEDIA_ENDPOINT,
27+
createUserOnSessionCreation: true,
28+
disableWebsocket: (typeof process.env.DISABLE_WEBSOCKET !== 'undefined') ? process.env.DISABLE_WEBSOCKET : false
29+
}

contrib/docker/start.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
cd api-server
4+
npm start

package.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"license": "Apache 2.0",
77
"scripts": {
88
"start": "node ./server.js",
9-
"test": "NODE_ENV=testing ./node_modules/.bin/mocha -r should -R spec"
9+
"test": "NODE_ENV=testing ./node_modules/.bin/mocha --timeout 5000 -r should -R spec"
1010
},
1111
"repository": {
1212
"type": "git",
@@ -18,11 +18,17 @@
1818
"ltx": "~0.3.0",
1919
"node-expat": "~2.0.0",
2020
"jwt-simple": "0.1.x",
21-
"iso8601": "1.1.1",
2221
"pubcontrol": "0.3.1",
2322
"grip": "0.1.4",
2423
"segfault-handler": "git+https://github.com/ddopson/node-segfault-handler.git",
25-
"node-xmpp-client": "~0.4.0"
24+
"node-xmpp-client": "~0.4.0",
25+
"primus-emitter": "~3.0.2",
26+
"primus": "~2.3.0",
27+
"xmpp-ftw": "~1.14.4",
28+
"xmpp-ftw-buddycloud": "~1.12.1",
29+
"socket.io": "~0.9.16",
30+
"winston": "0.7.x",
31+
"express-winston": "0.2.x"
2632
},
2733
"devDependencies": {
2834
"should": "~3.1.2",

0 commit comments

Comments
 (0)