0

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.

blackbourna
  • 1,223
  • 2
  • 16
  • 29
  • On which port is your server listening? – jpetazzo Aug 28 '12 at 05:00
  • It's listening on http 8080, and also TCP on 42801, which I was assigned by the environment.json file. The server runs fine if I started it manually by sshing into the dotcloud VM. The issue is with supervisord not autostarting and restarting the node server – blackbourna Aug 28 '12 at 13:08
  • 1
    Why do you think it comes from Supervisor? Did you try "supervisorctl status" to see what it says? – jpetazzo Aug 28 '12 at 22:17
  • Thanks for the suggestion, I've added the details to my question in an edit. – blackbourna Aug 28 '12 at 22:18

1 Answers1

2

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.

jpetazzo
  • 14,874
  • 3
  • 43
  • 45