Issues with hosting Strongloop Loopback server

330 views
Skip to first unread message

Grant Means

unread,
May 6, 2014, 4:24:37 PM5/6/14
to phusion-...@googlegroups.com
Hi,

I recently posted this over in the Loopback group. If anyone here has experience with Strongloop's Loopback API server I'd appreciate any input. Thanks!


I'm trying to deploy a Loopback application behind an NGINX / Passenger setup, however it doesn't appear to be starting up. Passenger is giving the following error:

An error occurred while starting the web application: it did not write a startup response in time. Please read this article for more information about this problem.

Reading the article they link to, it seems to indicate that passenger lost communication with the application which they indicate points to STDOUT redirection. From the article:

Stdout redirection

Phusion Passenger uses the application's stdout for communication with the application. This means that if, during any of those steps, stdout is closed, overwritten or redirected to a file, then Phusion Passenger loses its means to communicate with the application. After a while, Phusion Passenger concludes that the application fails to start up, and reports an error.

It is however safe to write data to stdout as long as the data does not begin with !>. Phusion Passenger uses !> to mark internal communication messages.


Phusion Passenger uses stdout and stderr to communicate with the application. It is safe for you to log messages to stdout and stderr, but don't do things like redirecting them to a file. Doing so will make Phusion Passenger think your app froze during startup, because it never receives a message back.

So my question is pretty much does Loopback do this?

I've tried the following to see if I can get it up and running:
  • Commented out all Console.log statements in the app.js file.
  • Replaced the loopback.bodyParser() lines with recommended loopback.json() and loopback.urlencoded() so the multipart error isn't logged.
  • Also 'node app.js' starts the app fine.
Does anyone have any experience with this?

Hongli Lai

unread,
May 8, 2014, 9:25:12 AM5/8/14
to phusion-passenger
Is the Loopback server an HTTP application that uses Node's
net.httpServer library?
Phusion Passenger only supports it if that's the case.
> --
> You received this message because you are subscribed to the Google Groups
> "Phusion Passenger Discussions" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to phusion-passen...@googlegroups.com.
> To post to this group, send email to phusion-...@googlegroups.com.
> Visit this group at http://groups.google.com/group/phusion-passenger.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/phusion-passenger/26f2aeb4-d96c-4f58-852a-a19337eac0eb%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Phusion | Web Application deployment, scaling, and monitoring solutions

Web: http://www.phusion.nl/
E-mail: in...@phusion.nl
Chamber of commerce no: 08173483 (The Netherlands)

Grant Means

unread,
May 8, 2014, 9:57:26 AM5/8/14
to phusion-...@googlegroups.com
Yes. According to their documentation it simply extends Express.

The App object extends Express and supports Express / Connect middleware. See Express documentation for details.

I asked about them redirecting stdout, but haven't received a response on that.

May 8, 2014 at 9:25 AM
Is the Loopback server an HTTP application that uses Node's
net.httpServer library?
Phusion Passenger only supports it if that's the case.



May 6, 2014 at 4:24 PM
Hi,

I recently posted this over in the Loopback group. If anyone here has experience with Strongloop's Loopback API server I'd appreciate any input. Thanks!


--
You received this message because you are subscribed to a topic in the Google Groups "Phusion Passenger Discussions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/phusion-passenger/zocCqXZ0ldI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to phusion-passen...@googlegroups.com.

--
Grant Means

Founder / Solution Architect

37 N. Orange Ave, Suite 500
Orlando, FL 32801
o: (407) 347-2467
c: (321) 287-4939

Senthuraan Ponnampalam

unread,
Jul 16, 2014, 2:58:39 AM7/16/14
to phusion-...@googlegroups.com, hon...@phusion.nl
Hi,

I have managed to run loopback app on passenger and nginx. 
There few things you have to do:

1.edit app.js
add following:

app.listen(function() {
    var baseUrl = 'http://' + app.get('host') + ':' + app.get('port');
    console.log('LoopBack server listening @ %s%s', baseUrl, '/');
    app.emit('started', baseUrl);
  });

Remove or comment this

// if(require.main === module) {
// app.start();
// }

2. You need to edit Loopback module file to avoid an error:
edit node_modules/loopback/lib/application.js
at the end of the file there is a section

 server.on('listening', function() {
    // self.set('port', server.address().port);
  });
 make it to look above.

passenger start will now work in stand alone.

Hope it helps.
Sendu

Líus Fontenelle Carneiro

unread,
Dec 18, 2014, 9:11:05 AM12/18/14
to phusion-...@googlegroups.com, hon...@phusion.nl
Hi,

I'm trying to run a Loopback application with Passenger + nginx, and running into the same problem. The actual version of loopback does not have a app.js file anymore.

Some advices?

Thanks!

Líus

Stephen Veit

unread,
Jan 20, 2016, 1:37:35 PM1/20/16
to Phusion Passenger Discussions, hon...@phusion.nl
Hi,

I has the same problem. It turns out that app.start() was not being called because it was checking if the file was passed to node. I commented out the lines that made the check:

// Bootstrap the application, configure models, datasources and middleware.
// Sub-apps like REST API are mounted via boot scripts.
boot(app, __dirname, function (err) {
  if (err) {
    throw err;
  }

  // start the server if `$ node server.js`
  // if (require.main === module) {
    app.start();
  //}
});

Now it starts and works properly.

Steve
Reply all
Reply to author
Forward
0 new messages