Skip to content

Commit

Permalink
modifications for passenger deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
joehobson committed Mar 25, 2021
1 parent 9469eb1 commit 58f95ea
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
8 changes: 4 additions & 4 deletions app.js
Original file line number Diff line number Diff line change
@@ -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");
Expand Down
14 changes: 12 additions & 2 deletions app/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand All @@ -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;
}
};
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 58f95ea

Please sign in to comment.