ddibiase
ddibiase

Reputation: 1502

Launching Node.js app on OpsWorks

I'm having trouble getting my OpsWorks custom recipe to launch my node application. I'm just starting to learn the fundamentals of Chef, so I may be missing something rather obvious.

To get me started I forked a copy of AWS nodejs cookbook and made very minor changes. I was also sure to copy the node deploy script here.

My layers are now fully configured and I can trigger node manually via SSH, however it seems that upon deploy it's not triggered by the Ruby script.

I'm assuming the start program line (which is the only place in the cookbook where I can see node being started) isn't getting run:

check host node_web_app_<%= @application_name %> with address 127.0.0.1
  start program = "/bin/bash -c 'cd <%= @deploy[:deploy_to] %>/current; source <%= @deploy[:deploy_to] %>/shared/app.env; /usr/bin/env PORT=<%= @deploy[:nodejs][:port] %> NODE_PATH=<%= @deploy[:deploy_to] %>/current/node_modules:<%= @deploy[:deploy_to] %>/current /usr/local/bin/node <%= @monitored_script %>' --NODE_ENV=prod"
  stop program = "/usr/bin/pkill -f 'node <%= @monitored_script %>'"
  <% if @deploy[:ssl_support] -%>
  if failed port <%= @deploy[:nodejs][:port] %> type TCPSSL protocol HTTP
  <% else -%>
  if failed port <%= @deploy[:nodejs][:port] %> protocol HTTP
  <% end -%>
    request /
    with timeout 10 seconds
    then restart

So I'm really at a loss for why it's not doing it's thing.

It almost seems as though this deploy cookbook wasn't fully completed. If there's a better cookbook available that someone can suggests, I'd consider changing.

Thanks.

Upvotes: 0

Views: 357

Answers (1)

Yousef
Yousef

Reputation: 401

Using the AWS opsworks nodejs layer, you should be able to set environment variables during App registration. You should see a section like this:

under app settings:

enter image description here

Where you can set all your variables to be included in the deployment.

Upvotes: 1

Related Questions