convert app to use express not restifiy so it works with metrics-sharelatex

This commit is contained in:
Henry Oswald 2015-03-02 18:13:28 +00:00
parent 876ea130b9
commit 7bbce79ff6
4 changed files with 7 additions and 31 deletions

View file

@ -2,19 +2,18 @@ Settings = require 'settings-sharelatex'
logger = require 'logger-sharelatex'
logger.initialize("spelling-sharelatex")
SpellingAPIController = require './app/js/SpellingAPIController'
restify = require 'restify'
express = require('express')
Path = require("path")
server = express()
bodyParser = require('body-parser')
metrics = require("metrics-sharelatex")
metrics.initialize("spelling")
metrics.mongodb.monitor(Path.resolve(__dirname + "/node_modules/mongojs/node_modules/mongodb"), logger)
HealthCheckController = require("./app/js/HealthCheckController")
server = restify.createServer
name: "spelling-sharelatex",
version: "0.0.1"
server.use restify.bodyParser(mapParams: false)
server.use bodyParser.json()
server.use metrics.http.monitor(logger)
server.post "/user/:user_id/check", SpellingAPIController.check

View file

@ -1,23 +0,0 @@
StatsD = require('node-statsd').StatsD
statsd = new StatsD('localhost',8125)
buildKey = (key)-> "spelling.#{process.env.NODE_ENV}.#{key}"
module.exports =
inc : (key, sampleRate)->
statsd.increment buildKey(key, sampleRate)
Timer : class
constructor :(key)->
this.start = new Date()
this.key = buildKey(key)
done:->
timeSpan = new Date - this.start
statsd.timing("#{this.key}-time", timeSpan)
statsd.increment "#{this.key}-count"
gauge : (key, value, sampleRate)->
stats = {};
stat = buildKey(key)
stats[stat] = value+"|g";
statsd.send(stats, sampleRate);

View file

@ -1,7 +1,7 @@
SpellingAPIManager = require './SpellingAPIManager'
restify = require 'restify'
logger = require 'logger-sharelatex'
metrics = require('./Metrics')
metrics = require('metrics-sharelatex')
module.exports = SpellingAPIController =
check: (req, res, next) ->

View file

@ -9,14 +9,14 @@
"version": "0.1.3",
"dependencies": {
"async": "0.1.22",
"express": "3.1.0",
"body-parser": "^1.12.0",
"express": "^4.12.1",
"logger-sharelatex": "git+https://github.com/sharelatex/logger-sharelatex.git#v1.0.0",
"metrics-sharelatex": "git+https://github.com/sharelatex/metrics-sharelatex.git#v1.0.0",
"mongojs": "0.9.11",
"node-statsd": "0.0.3",
"redis": "~0.8.4",
"request": "^2.53.0",
"restify": "2.5.1",
"settings-sharelatex": "git+https://github.com/sharelatex/settings-sharelatex.git#v1.0.0",
"underscore": "1.4.4",
"v8-profiler": "^5.2.4"