-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.js
executable file
·40 lines (34 loc) · 1.02 KB
/
example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env node
'use strict';
var http = require('http');
var mongo = require('mongodb').MongoClient;
var server = require('./lib/server');
var sessionManager = require('./lib/session-manager');
var mongoUrl = 'mongodb://localhost:27017/rv';
mongo.connect(mongoUrl, function(err, db) {
if (err) {
throw err;
}
sessionManager.setup(db, {trafficStoreTimeout: 5000});
server(function() {
console.log('Remote View worker is up and running on %d', this.address().port);
// create a test session for given url
var sessionId = '__test-session';
var localSite = 'http://emmet.io';
var publicId = 'rv-test.livestyle.local:9001';
db.collection('Session').update({_id: sessionId}, {$set: {
_id: sessionId,
user: 0,
publicId: publicId,
localSite: localSite,
created: Date.now(),
expiresAt: Date.now() + 24 * 60 * 60 * 1000,
active: true
}}, {upsert: true}, function(err) {
if (err) {
throw err;
}
console.log('Created temp session for local http://%s → %s', publicId, localSite);
});
});
});