Search code examples
javascriptnode.jsdeploymentdotcloudsupervisord

Dotcloud nodejs supervisord.conf not working


I've been trying to get my nodejs server process to be monitored by supervisor, however I'm having issues getting supervisord.conf to work. When I deploy, I get the following error:

WARNING: The service crashed at startup or is listening to the wrong port. It failed to respond on port "node" (42801) within 30 seconds. Please check the application logs.

However when I ssh into the dotcloud server and manually start the nodejs process, it runs just fine, indicating that supervisor is failing to start the node instance.

My supervisord.conf looks like this:

[program:node]
command = node /home/dotcloud/current/app/server.js
autostart=true
autorestart=true

And my directory structure is as follows:

.dotcloudignore
dotcloud.yml
.gitignore
app/
app/package.json
app/server.js
app/supervisord.conf

At this point, I can't see what I'm doing wrong, as this appears to be the same directory structure as outlined here, so I'm kind of at a loss as to what the solution is. Any ideas?

Edit:

After trying a supervisorctl status I get the following:

node                             FATAL      Exited too quickly (process log may have details)

I've found that in /var/log/supervisor, I'm getting the following error message:

module.js:337
    throw new Error("Cannot find module '" + request + "'");
          ^
Error: Cannot find module '/home/dotcloud/current/app/server.js'
    at Function._resolveFilename (module.js:337:11)
    at Function._load (module.js:279:25)
    at Array.0 (module.js:484:10)
    at EventEmitter._tickCallback (node.js:190:38)

I'm not sure what is causing this.


Solution

  • After investigating the issue, it looks like the issue came from the fact that dotcloud.yml specified approot: app. In that case, it is useful to note that:

    • /home/dotcloud/code will point to the whole code repository;
    • /home/dotcloud/current will point to the approot (more specifically, /home/dotcloud/current will be a symlink to the approot, i.e. code/app in that case).

    Therefore, supervisord.conf should not contain:

    command = node /home/dotcloud/current/app/server.js
    

    But, instead:

    command = node /home/dotcloud/current/server.js
    

    The key was in the Node.js logs themselves, since Node.js was complaining about being unable to locate /home/dotcloud/current/app/server.js.