Skip to content

Commit

Permalink
Make the port for Node.js apps configurable and make it available to …
Browse files Browse the repository at this point in the history
…apps as PORT environment variable.
  • Loading branch information
githuesch committed Apr 28, 2014
1 parent 57c145b commit ca1ad6e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions deploy/attributes/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
# nodejs
default[:deploy][application][:nodejs][:restart_command] = "monit restart node_web_app_#{application}"
default[:deploy][application][:nodejs][:stop_command] = "monit stop node_web_app_#{application}"
default[:deploy][application][:nodejs][:port] = 80
end

default[:opsworks][:skip_uninstall_of_other_rails_stack] = false
Expand Down
4 changes: 2 additions & 2 deletions opsworks_nodejs/templates/default/node_web_app.monitrc.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
check host node_web_app_<%= @application_name %> with address 127.0.0.1
start program = "/bin/sh -c 'cd <%= @deploy[:deploy_to] %>/current; /usr/bin/env NODE_PATH=<%= @deploy[:deploy_to] %>/current/node_modules:<%= @deploy[:deploy_to] %>/current /usr/local/bin/node <%= @monitored_script %>'"
start program = "/bin/sh -c 'cd <%= @deploy[:deploy_to] %>/current; /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 %>'"
stop program = "/usr/bin/pkill -f 'node <%= @monitored_script %>'"
if failed port 80 protocol HTTP
if failed port <%= @deploy[:nodejs][:port] %> protocol HTTP
request /
with timeout 10 seconds
then restart

0 comments on commit ca1ad6e

Please sign in to comment.