Skip to content

Commit

Permalink
Merge pull request #176 from tomvantilburg/master
Browse files Browse the repository at this point in the history
New way of deploying superpeer with config file
  • Loading branch information
tomvantilburg committed Mar 18, 2015
2 parents 1427a51 + 2c78e1b commit 0b5cb56
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 47 deletions.
2 changes: 1 addition & 1 deletion dist/cow.js
Original file line number Diff line number Diff line change
Expand Up @@ -2820,7 +2820,7 @@ Cow.core = function(config){
if (typeof(config) == 'undefined' ) {
config = {};
}
this._version = '2.0.2';
this._version = '2.0.3';
this._herdname = config.herdname || 'cow';
this._userid = null;
this._socketserverid = null;
Expand Down
2 changes: 1 addition & 1 deletion dist/cow.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/cow.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -2752,7 +2752,7 @@ Cow.core = function(config){
if (typeof(config) == 'undefined' ) {
config = {};
}
this._version = '2.0.2';
this._version = '2.0.3';
this._herdname = config.herdname || 'cow';
this._userid = null;
this._socketserverid = null;
Expand Down
2 changes: 1 addition & 1 deletion dist/cow.node.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/cow2.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Cow.core = function(config){
if (typeof(config) == 'undefined' ) {
config = {};
}
this._version = '2.0.2';
this._version = '2.0.3';
this._herdname = config.herdname || 'cow';
this._userid = null;
this._socketserverid = null;
Expand Down
8 changes: 8 additions & 0 deletions src/superpeer/ontw.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"dbUrl": "tcp://geodan:[email protected]/cow",
"herdname":"ontw",
"protocol": "wss",
"ip": "websocket.geodan.nl",
"port": 443,
"dir": "ontw"
}
41 changes: 0 additions & 41 deletions src/superpeer/pg_test.js

This file was deleted.

16 changes: 16 additions & 0 deletions src/superpeer/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Make a new superpeer with:
```
node superpeer.js config.json
```

Config file should look like:
```
{
"dbUrl": "tcp://user:pass@ip/db",
"herdname":"blabla",
"protocol": "wss",
"ip": "ip.to.socketserver",
"port": 443,
"dir": "blabla"
}
```
4 changes: 3 additions & 1 deletion src/superpeer/speer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
_ = require('../../node_modules/underscore/underscore.js')._
Promise = require('../../node_modules/es6-promise').Promise;
Events = require('../../src/events.js');
//log = require('../../lib/loglevel/loglevel.min.js');



/**
!! websocket source code has been changed !!
node_modules/websocket/lib/WebSocketClient.js, line 251
Expand Down
39 changes: 39 additions & 0 deletions src/superpeer/superpeer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
configfile = process.argv[2];
config = require('./'+ configfile);

_ = require('../../node_modules/underscore/underscore.js')._
Promise = require('../../node_modules/es6-promise').Promise;
Events = require('../../src/events.js');

WebSocket = require('websocket').client;
pg = require('pg').native;
//Set global dbUrl
GLOBAL.dbUrl = config.dbUrl;
//Set env var to accept all certificates
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
Cow = require('./cow.node.js');


core = new Cow.core({
herdname: config.herdname,
maxage: 1000 * 60 * 60 * 24 * 365 //one year
});
core.socketservers({
_id: 'default',
data: {
protocol:config.protocol,
ip:config.ip,
port:config.port,
dir: config.dir}
});
core.socketserver('default');
core.connect();
core.userStore().loaded.then(function(){
console.log(core.users().length, ' users loaded');
});

core.projectStore().loaded.then(function(){
console.log(core.projects().length, ' projects loaded');
core.peer().data('superpeer', true).sync();
console.log('My peerid: ', core.peerid()); //dirty hack
});

0 comments on commit 0b5cb56

Please sign in to comment.