2

I created a new NodeJS site based on the documentation of Durandal. It works locally. I set up Windows Azure to pull in the changes of my GitHub repository, which it does correctly.

However, (after enabling errors) I'm getting the an internal server error.

I checked my FTP for the logs, but don't have any. There is a 'Git' folder, but nothing interesting there.

When I change my server.js file to the hello world sample, everything works:

var http = require('http')
var port = process.env.PORT || 1337;
http.createServer(function(req, res) {
    res.writeHead(200, { 'Content-Type': 'text/plain' });
    res.end('Hello World\n');
}).listen(port);

This is my server.js now:

var express = require('express'),
    routes = require('./routes'),
    engines = require('consolidate');

exports.startServer = function(config, callback) {

  var port = process.env.PORT || config.server.port || 1337;
  var app = express();
  var server = app.listen(port, function() {
    console.log("Express server listening on port %d in %s mode", server.address().port, app.settings.env);
  });

  app.configure(function() {
    app.set('port', port);
    app.set('views', config.server.views.path);
    app.engine(config.server.views.extension, engines[config.server.views.compileWith]);
    app.set('view engine', config.server.views.extension);
    app.use(express.favicon());
    app.use(express.bodyParser());
    app.use(express.methodOverride());
    app.use(express.compress());
    app.use(config.server.base, app.router);
    app.use(express.static(config.watch.compiledDir));
  });

  app.configure('development', function() {
    app.use(express.errorHandler());
  });

  app.get('/', routes.index(config));

  callback(server);
};

So, has anyone succesfully hosted an Express (or more specifically, the Durandal skeleton for Mimosa) NodeJS site on Windows Azure? Or do you know how or where I can find the internal server error?

Peter
  • 13,733
  • 11
  • 75
  • 122
  • If you get this figured out, I'd love to know the steps it takes to turn a vanilla Mimosa/Durandal app into something hosted with Azure. Sort of like the Heroku steps: http://mimosa.io/about.html#Heroku – David Bashford Mar 27 '14 at 01:18
  • I'm currently working on it (in my free time). I will definitely let you know. Mark's answer got me started on a new path. I'll update when I found the solution. – Peter Mar 27 '14 at 14:38
  • @DavidBashford I've got it to work and [blogged](http://petermorlion.blogspot.be/2014/03/getting-mimosa-durandal-app-to-work-on.html) about it extensively. In short, you need to get Azure to pull in the /dist contents and start app.js, not server.js. – Peter Mar 31 '14 at 15:57

1 Answers1

1

I've launched a few express applications on the Windows Azure platform and found that I had several instances of it failing quite silently. I personally have found the approach suggested in this post by Jay Harris really helpful as it allows me to import dependencies (npm, bower or other) and run grunt tasks to compile the project etc.

A few things worth noting is that often after a new deploy the updates did not display until restarting the Azure server in the control panel. Sometimes the deploy scripts timed out and I had to check them regularly.

This doesn't exactly answer what's wrong with your code (sorry) but I've posted an example using the method mentioned above that may help. The main deploy files are 'web.config', 'deploy.sh' and '.deployment' as well as your 'package.json' file.

Mark
  • 26
  • 2
  • I've put all the details in a [blog post](http://petermorlion.blogspot.be/2014/03/getting-mimosa-durandal-app-to-work-on.html), but you're correct that the most important bits are the web.config and deploy.sh (.cmd in my case). – Peter Mar 31 '14 at 15:56
  • 1
    Read through your blog post and looks all good. I haven't used Mimosa but it looks like you could do what I've done with Grunt. In `deploy.sh` after installing the npm packages (with mimosa) you could call a Mimosa (build -omp) command to compile the application into your `/dist` directory. That way you shouldn't have to commit any compiled code to your repo and just keep it clean with dev files. – Mark Apr 30 '14 at 21:12