diff --git a/node/newsblur.coffee b/node/newsblur.coffee index 1c83bc05e..3a2c1389c 100644 --- a/node/newsblur.coffee +++ b/node/newsblur.coffee @@ -10,35 +10,44 @@ if envresult.error if envresult.error throw envresult.error +ENV_DEV = process.env.NODE_ENV == 'development' +ENV_PROD = process.env.NODE_ENV == 'production' +ENV_DOCKER = process.env.NODE_ENV == 'docker' + original_page = require('./original_page.js').original_page original_text = require('./original_text.js').original_text favicons = require('./favicons.js').favicons unread_counts = require('./unread_counts.js').unread_counts +if not ENV_DEV and not ENV_PROD and not ENV_DOCKER + throw new Error("Set envvar NODE_ENV=") -Sentry.init({ - dsn: process.env.SENTRY_DSN, - integrations: [ - new Sentry.Integrations.Http({ tracing: true }), - new Tracing.Integrations.Express({ - app - }) - ], - tracesSampleRate: 1.0 -}) +if ENV_PROD + Sentry.init({ + dsn: process.env.SENTRY_DSN, + integrations: [ + new Sentry.Integrations.Http({ tracing: true }), + new Tracing.Integrations.Express({ + app + }) + ], + tracesSampleRate: 1.0 + }) -app.use(Sentry.Handlers.requestHandler()) -app.use(Sentry.Handlers.tracingHandler()) + app.use(Sentry.Handlers.requestHandler()) + app.use(Sentry.Handlers.tracingHandler()) original_page(app) original_text(app) favicons(app) unread_counts(server) -app.get "/debug", (req, res) -> - throw new Error("Debugging Sentry") +if ENV_PROD + app.get "/debug", (req, res) -> + throw new Error("Debugging Sentry") -app.use(Sentry.Handlers.errorHandler()) + app.use(Sentry.Handlers.errorHandler()) + log.debug "Setitng up Sentry debugging: #{process.env.SENTRY_DSN.substr(0, 20)}..." log.debug "Starting NewsBlur Node Server: #{process.env.SERVER_NAME}" server.listen(8008) diff --git a/node/newsblur.js b/node/newsblur.js index 28fb8c5bd..5a9fd0bc3 100644 --- a/node/newsblur.js +++ b/node/newsblur.js @@ -1,6 +1,6 @@ // Generated by CoffeeScript 2.5.1 (function() { - var Sentry, Tracing, app, envresult, favicons, log, original_page, original_text, server, unread_counts; + var ENV_DEV, ENV_DOCKER, ENV_PROD, Sentry, Tracing, app, envresult, favicons, log, original_page, original_text, server, unread_counts; Sentry = require("@sentry/node"); @@ -24,6 +24,12 @@ } } + ENV_DEV = process.env.NODE_ENV === 'development'; + + ENV_PROD = process.env.NODE_ENV === 'production'; + + ENV_DOCKER = process.env.NODE_ENV === 'docker'; + original_page = require('./original_page.js').original_page; original_text = require('./original_text.js').original_text; @@ -32,20 +38,24 @@ unread_counts = require('./unread_counts.js').unread_counts; - Sentry.init({ - dsn: process.env.SENTRY_DSN, - integrations: [ - new Sentry.Integrations.Http({ - tracing: true - }), - new Tracing.Integrations.Express({app}) - ], - tracesSampleRate: 1.0 - }); + if (!ENV_DEV && !ENV_PROD && !ENV_DOCKER) { + throw new Error("Set envvar NODE_ENV="); + } - app.use(Sentry.Handlers.requestHandler()); - - app.use(Sentry.Handlers.tracingHandler()); + if (ENV_PROD) { + Sentry.init({ + dsn: process.env.SENTRY_DSN, + integrations: [ + new Sentry.Integrations.Http({ + tracing: true + }), + new Tracing.Integrations.Express({app}) + ], + tracesSampleRate: 1.0 + }); + app.use(Sentry.Handlers.requestHandler()); + app.use(Sentry.Handlers.tracingHandler()); + } original_page(app); @@ -55,11 +65,13 @@ unread_counts(server); - app.get("/debug", function(req, res) { - throw new Error("Debugging Sentry"); - }); - - app.use(Sentry.Handlers.errorHandler()); + if (ENV_PROD) { + app.get("/debug", function(req, res) { + throw new Error("Debugging Sentry"); + }); + app.use(Sentry.Handlers.errorHandler()); + log.debug(`Setitng up Sentry debugging: ${process.env.SENTRY_DSN.substr(0, 20)}...`); + } log.debug(`Starting NewsBlur Node Server: ${process.env.SERVER_NAME}`);