Web UI - "Caught exception ... Couldn't connect to the renderer."

I’m in the process of setting up a replica server with hourly updates and have run in to a problem getting the web server to start correctly. I’m following the INSTALL.md documentation from GitHub.

The problem seems to be related to starting the web server as a service via Upstart (Ubuntu 14.04). If I start the web server as a non-root user from the command line, the web server starts normally and functions as expected. However, if I start the web server using the same command as the same non-root user via Upstart I get the following errors when I attempt to view the home page.

Log output of first web request after starting the app with upstart:

10.0.2.2 - - [30/Jun/2017:00:12:10 +0000] "GET / HTTP/1.1" 500 149558 "-" "Mozilla/5.0 (Macintosh; Intel 
Mac OS X 10_12_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36"
[info] *** Request 1 (0.050/s) [8109] [Fri Jun 30 00:12:00 2017] ***
[debug] Path is "/"
[debug] "GET" request for "/" from "10.0.2.2"
[debug] Found sessionid "67994cbdca61bf955ac90127ee7b018bd4c48b4e" in cookie
[debug] Restored session "67994cbdca61bf955ac90127ee7b018bd4c48b4e"
[error] Caught exception in MusicBrainz::Server::View::Default->process "Couldn't connect to the renderer. at 
/home/musicbrainz/musicbrainz-server/lib/MusicBrainz/Server/View/Base.pm line 36."

Screen shot of browser output:

Anyone have an idea of what might be going on here?

First, make sure Node.js dependencies are up-to-date, see INSTALL.md, and available from Upstart.

Then, make sure socket can be opened (usually in /tmp/musicbrainz-template-renderer.socket) from Upstart.

Otherwise, it might be related to bug MBS-9370.

I narrowed it down to a path issue. For reasons unclear, plackup was unable to find perl via the !#/usr/bin/env perl directive. I was able to resolve the issue by loading the shell environment for my musicbrainz user in a single command. (as opposed to using the upstart setusr and setgid directives)

exec su - musicbrainz -c 'cd /home/musicbrainz/musicbrainz-server && eval $( perl -Mlocal::lib ) && plackup -Ilib -r'