diff --git a/app.js b/app.js index 5554f76..1070409 100644 --- a/app.js +++ b/app.js @@ -1,8 +1,8 @@ -"use strict"; +const path = require("path"); -require("dotenv").config(); -// unsplash-js requires fetch to be available in the global scope -// see: https://github.com/unsplash/unsplash-js#adding-polyfills +require("dotenv").config({ + path: path.join(__dirname, ".env") +}); global.fetch = require("node-fetch"); const container = require("./app/container"); diff --git a/app/application.js b/app/application.js index a380a6c..28fbbc2 100644 --- a/app/application.js +++ b/app/application.js @@ -6,6 +6,10 @@ const withMiddleware = require("./middleware"); const _env = require("./env"); const _routes = require("./routes"); +if (typeof PhusionPassenger !== "undefined") { + PhusionPassenger.configure({ autoInstall: false }); +} + function inject(provide) { return [_env, _routes, provide(console), provide(express()), _stats]; } @@ -16,8 +20,14 @@ function init(env, routes, logger, app, stats) { const port = env.get("PORT", () => 3000); return { listen() { - const server = app.listen(port); - logger.log(`Rich Content Service listening on port ${port}`); + var server = null; + if (typeof PhusionPassenger !== "undefined") { + logger.log("we are running in phusion"); + server = app.listen("passenger"); + } else { + logger.log("we are running outside of phusion, on port " + port); + server = app.listen(port); + } return server; } }; diff --git a/package-lock.json b/package-lock.json index fb9119b..2b867d4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "canvas-rce-api", - "version": "1.14.0", + "version": "1.15.0", "lockfileVersion": 1, "requires": true, "dependencies": {