Search code examples
node.jsiisexecwindows-server-2012iisnode

IISNode exec silently failing


I'm trying to build a automatic code pulling service with GitHub webhooks and node.js. When I ran this code yesterday it worked like a charm and pulled the right repository to the right folder but today it just started to silently fail. It works on my development machine.

As stated in the tile I'm using IISNode to run it under IIS but I'm starting to wonder if I should just host it without IIS. This is the code I've written.

var exec    =   require('child_process').exec,
http    =   require('http'),
path    =   require('path'),
config  =   require('./config'),
server  =   http.createServer(function(req, res) {

var incomingData = '';

req.on('data', function(data) {
    incomingData += data;
});

req.on('end', function() {
    incomingData = JSON.parse(incomingData);
    var repoName = incomingData.repository.name;
    var pullPath = path.resolve('..', repoName);

    console.log(pullPath);
    var body = "<html><body>stdout: ";
    exec('cd ' + pullPath + ' && git pull', function (error, stdout, stderr) {
        if( error !== null ){
            console.log(error);
        }

        console.log("stdout: " + stdout);
        console.log("stderr: " + stderr);
        body += stdout;
    });
    body += "</body></html>";

        res.writeHead(200, {
          'Content-Length': body.length,
          'Content-Type': 'text/plain' });
        res.write(body, 'utf8');
        res.end();
    });
}).listen(config.web.port);

Why has this suddenly stopped working?

edit: I have opened a issue on issnode's github page for this. https://github.com/tjanczuk/iisnode/issues/352

edit2: Adding some debugging info http://tjanczuk.github.io/iisnode/iisnode-debug.html#iisnode_ver=0.2.11&node=node.exe&dns=DNS&worker_pid=600&node_pid=1200&worker_mem_ws=11072&worker_mem_pagefile=4728&node_mem_ws=12820&node_mem_pagefile=12696&app_processes=1&process_active_req=1&app_active_req=1&worker_total_req=1&np_retry=1&req_time=0&hresult=0

edi3: It seems I have problems going to .../app.js/debug/ it gets the title but then seems to be waiting forever to get a response from the server.


Solution

  • I figured out what was wrong, I didn't have the github credentials saved for IISNode. I "hacked" it by pointing the home to my Admin-user (with github ssh key).

    I figured it out by some more googling and realised I was spawning a lot of git instances that didn't seem to resolve (they were waiting for my input of password).