-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
126 lines (104 loc) · 4.25 KB
/
app.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
var Hapi = require('hapi');
var util = require('util');
var Path = require('path');
var Yar = require('yar');
var logger = require('./config/logger.js');
//var db = require('./lib/datastores/rethinkdb/init.js');
var C = require('./lib/datastores/rethinkdb/connection.js');
var AccountsApp = require('./lib/web/accounts');
var Api = require('./lib/web/api');
var CommandListenerService = require('./services/command_listener_service.js');
var server = new Hapi.Server({
debug: { request: ['error', 'uncaught'] }
});
C.createConnection(startServer);
function startServer(dbConn){
if(process.env.NODE_ENV != 'REPL')
if(!process.env.cookieOptionsPassword)
process.env.cookieOptionsPassword = 'piperatthegatesofdawniscallingyouhisway';
console.log("Start server started Connection Open " + dbConn.open);
console.log('Connection available');
var port = process.env.PORT || 4005;
server.connection({port: port});
var yarOptions = {
name: '_zuleikha_es_flash',
cookieOptions: {
password: 'piperatthegatesofdawniscallingyouhisway',
isSecure: false,
}
}
server.register([{
register: Yar,
options: yarOptions
},{
register: AccountsApp,
options: {}
},{
register: Api,
options: {}
}], function(err){
if(err)
throw err;
})
process.on('uncaughtException', function(err){
console.log(err);
throw err;
})
server.start(function(){
var commandListenerInitialized = function(){
console.log('Server connected to port ' + server.info.uri);
//var serviceBus = require('./config/servicebus.js');
//
//var constants = require('./config/constants.js');
//commandListenerService.init();
//console.log('Started Command Listener');
//
//var nameS = require('./services/name_generator_service.js');
//var channelName = nameS.getQueueName('42d19749-fb48-4373-8f7a-b80170255644',
// 'test_stream_10')
//console.log("SUBSCRIBED TO CHANNEL " + channelName);
//
//
//serviceBus.subscribe(channelName, function(event){
// console.log(' ======================================================================= ')
// console.log(util.inspect(event));
// console.log(' ======================================================================= ')
//})
//
//
//
//
//var subscriptionQueueName = channelName + '.responses'
//setTimeout(function(){
// serviceBus.publish('eventstore.commands',{
// command:'unsubscribeEvent',
// accountId: '42d19749-fb48-4373-8f7a-b80170255644',
// streamName: 'test_stream_10'
// })
//}, 10000)
console.log('Sending subscribeCatchupStreamEvent');
//serviceBus.publish('eventstore.commands', {
// accountId: '42d19749-fb48-4373-8f7a-b80170255644',
// streamName: 'test_stream_10',
// startSequenceId: 1000,
// endSequenceId: 2000,
// command: 'subscribeCatchupStreamEvent'
//})
/*var i =0;
setInterval(function(){
++i;
serviceBus.publish('eventstore.commands', {
command: 'newEvent',
accountId: '42d19749-fb48-4373-8f7a-b80170255644',
streamName: 'test_stream_10',
eventAttributes: {
timestamp: new Date(),
number: i
}
})
}, 12)*/
}
CommandListenerService.init(commandListenerInitialized);
});
}
module.exports = server;