1

What is the best practice for using Phusion Passenger with a version of node installed my nvm?


In this tutorial on using Passenger to run a Meteor app, I read:

[Y]our Meteor application is run as ... the owner of the main.js file (when deploying a Meteor bundle), unless you configure it otherwise. Of course you still have to make sure that each of your applications is owned by another user.

Meteor 1.6 works with Node.js v8.8.1, so I have used nvm to install node. I created a special meteor user to run the nvm installation of node and nvm. Node was therefore installed at /home/meteor/.nvm/versions/node/v8.8.1/bin/node, and /home/meteor/.nvm/versions/node/v8.8.1/bin/ was added to the $PATH variable for my meteor user. As a result, calling node -v as the meteor user showed that v8.8.1 was installed and accessible.

I followed this tutorial to deploy my Meteor app to my server.

As the meteor user from within the bundle/programs/server directory, I ran npm install --production. I made meteor the owner of everthing inside bundle/.

I had expected that Passenger would launch node as the meteor user, and that everything would run smoothly. Instead, Passenger showed a useful alert page, apologising that "something went wrong".

To work around this, I created a symlink at /usr/bin/node to point at /home/meteor/.nvm/versions/node/v8.8.1/bin/node, and now Passenger was happy to launch the bundled app.

This suggests to me that Passenger was not running main.js as the meteor user. Or is there another reason why the meteor user was not able to see its own version of node?

The quote above suggests that it is possible to configure which user Passenger uses. How do I do that?

In a nutshell: what is the official Passenger method for working with a version of node installed by nvm?

James Newton
  • 6,623
  • 8
  • 49
  • 113

1 Answers1

2

You'll want to set the version of node to the full path to the nvm node: https://www.phusionpassenger.com/library/config/standalone/reference/#--nodejs-nodejs

As for the user-switching, you can set the log-level to 7 (https://www.phusionpassenger.com/library/config/standalone/reference/#--log-level-log_level) in order to debug that and either go through the startup logs yourself or post them here.

Camden Narzt
  • 2,271
  • 1
  • 23
  • 42