2017-09-08 01:27:03 +08:00
|
|
|
redis = require("redis")
|
|
|
|
|
2014-11-11 04:11:09 +08:00
|
|
|
config = require("./config")
|
2014-11-13 02:35:25 +08:00
|
|
|
Hook = require("./hook")
|
2014-11-13 22:15:20 +08:00
|
|
|
IDMapping = require("./id_mapping")
|
2014-11-11 21:58:28 +08:00
|
|
|
WebHooks = require("./web_hooks")
|
|
|
|
WebServer = require("./web_server")
|
2014-11-11 03:32:51 +08:00
|
|
|
|
2014-11-11 21:20:55 +08:00
|
|
|
# Class that defines the application. Listens for events on redis and starts the
|
|
|
|
# process to perform the callback calls.
|
2014-11-15 00:12:37 +08:00
|
|
|
# TODO: add port (-p) and log level (-l) to the command line args
|
2014-11-11 03:32:51 +08:00
|
|
|
module.exports = class Application
|
|
|
|
|
|
|
|
constructor: ->
|
2017-09-08 01:27:03 +08:00
|
|
|
# one for pub/sub, another to read/write data
|
|
|
|
config.redis.pubSubClient = redis.createClient()
|
|
|
|
config.redis.client = redis.createClient()
|
|
|
|
|
2014-11-11 21:58:28 +08:00
|
|
|
@webHooks = new WebHooks()
|
|
|
|
@webServer = new WebServer()
|
2014-11-11 03:32:51 +08:00
|
|
|
|
|
|
|
start: ->
|
2014-11-13 02:35:25 +08:00
|
|
|
Hook.initialize =>
|
2014-11-13 22:15:20 +08:00
|
|
|
IDMapping.initialize =>
|
2014-11-13 02:35:25 +08:00
|
|
|
@webServer.start(config.server.port)
|
|
|
|
@webHooks.start()
|