Search code examples
node.jsnginxpassengerpleskprobot

Phusion Passenger: Error starting web application - Deploying Probot app (NodeJS) with Plesk nginx


I'm trying to deploy a GitHub Probot App (NodeJS application) to my webserver running Plesk 18.0.27 U1 with the NodeJS Extension 1.3.6-117. When running the probot app on my local machine, the app starts just fine and is accessible via localhost.

Plesk is apparently using the Phusion Passenger application server to serve NodeJS apps.
When accessing the deployed website, I get the following errror:

Screenshot: Passenger problem location

And in /var/log/nginx/error.log:

[ E 2020-05-30 10:06:31.7393 21506/Th age/Cor/App/Implementation.cpp:221 ]: Could not spawn process for application /var/www/vhosts/example.org/node_root: A timeout occurred while spawning an application process.
  Error ID: 5f02dec5
  Error details saved to: /tmp/passenger-error-y6AeCv.html

[ E 2020-05-30 10:06:31.7466 21506/T5 age/Cor/Con/CheckoutSession.cpp:276 ]: [Client 1-2] Cannot checkout session because a spawning error occurred. The identifier of the error is 5f02dec5. Please see earlier logs for details about the error.


Things I've tested so far

  • I increased the timeout for starting the app in nginx passenger_start_timeout 300;
  • I disabled php and proxy_mode in Plesk for this website (Nginx proxies requests to Apache by default, but passenger is running on nginx only)
  • I wrote a custom startup script to disable passenger autoinstall and set the webserver port in the node dotenv file to PORT="passenger"
#!/usr/bin/env node

const { Probot } = require('Probot')

// @ts-ignore
if (typeof(PhusionPassenger) !== 'undefined') {
    //@ts-ignore
    PhusionPassenger.configure({ autoInstall: false });
}

Probot.run(process.argv)

Starting questions

Is my application failing or is passenger unable to bind the port of the app?

Are there more detailed logs or an option to enable verbose output?

Thanks in advance!


Solution

  • After long research I figured it out myself. Posting my solution in case anyone is dealing with the same problem.

    1. Setting the passenger log level. You can put passenger_log_level 7 in your nginx configuration /etc/nginx/conf.d/phusion-passenger.conf (for Plesk)

    2. I started the app as a standalone passenger server and got the actual application stdout output. Example: cd in your node app root-folder and run passenger start --startup-file lib/startup.js --nodejs /opt/plesk/node/12/bin/node --log-level 3 --app-type node.

    At this point I saw the module Probot couldn't be found in my above mentioned startup script. So I dug a little deeper how a probot app is actually started and stumbled upon the probot run command. By default a probot app isn't run with node ./lib/index.js but probot run ./lib/index.js.

    1. Using a custom passenger app start command. I added the nginx option passenger_app_start_command "/opt/plesk/node/12/bin/npm start"; to set the custom start command to use the probot run command defined in the package.json start script instead of the default node ./lib/startup.js from passenger

    I learned a lot about these tools and hope this will save someones weekend :D