Search code examples
node.jsdotcloud

Webservice/worker service deploying to dotcloud


I'm trying to deploy a node.js app to dotcloud.

The instructions are found on this page:

https://docs.dotcloud.com/#nodejs.html

I found it confusing, it doesn't explain the final result of the files that you need to create.

If I'm just doing a simple website, do I need a 'worker' service?

If I do, are there any tutorials for how to program node.js sites with separate workers and 'web' services? I've no idea...

This is my supervisor.conf

[program:node]
command = NODE_ENV=production node server.js
directory = /home/dotcloud/current

My dotcloud.yml:

mynodejswebservice:
  type: nodejs

Is this correct? Do we have to replace the directory?


Solution

  • For NodeJS on Dotcloud, the web server is just a type of a worker service.

    Your supervisord.conf is correct, you don't need to change the directory. Although I'm not sure about the "NODE_ENV=production" inside the command.

    You can add environment variables by adding this to the supervisord.conf:

    environment = NODE_ENV=production
    

    See here for more info: http://supervisord.org/configuration.html?highlight=environment

    See here for an example of a node supervisord.conf on dotcloud: https://github.com/andzdroid/Batteries/blob/master/www/supervisord.conf

    If you want to run another worker service, your supervisord.conf will look the same, you just need to change the command:

    [program:node]
    command = node worker.js