Skip to content

Instantly share code, notes, and snippets.

@chris
Created May 13, 2011 05:55
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save chris/970051 to your computer and use it in GitHub Desktop.
Save chris/970051 to your computer and use it in GitHub Desktop.
Chef recipe to install node.js on Engine Yard AppCloud
#
# Cookbook Name:: nodejs
# Recipe:: default
#
# Build and install node.js
#
if ['app','app_master','solo'].include?(node[:instance_role])
version_tag = "v0.4.8"
source_base_dir = "/data/nodejs"
source_dir = "#{source_base_dir}/#{version_tag}"
install_dir = "/usr/local/bin"
ey_cloud_report "node.js" do
message "Setting up node.js"
end
ey_cloud_report "nodejs" do
message "configuring nodejs #{version_tag}"
end
directory "#{source_base_dir}" do
owner 'root'
group 'root'
mode 0755
recursive true
end
# download nodejs source and checkout specific version
execute "fetch nodejs from GitHub" do
command "git clone https://github.com/joyent/node.git #{source_dir} && cd #{source_dir} && git checkout #{version_tag}"
not_if { FileTest.exists?(source_dir) }
end
# compile nodejs
execute "configure nodejs" do
command "cd #{source_dir} && ./configure"
not_if { FileTest.exists?("#{source_dir}/node") }
end
execute "build nodejs" do
command "cd #{source_dir} && make"
not_if { FileTest.exists?("#{source_dir}/node") }
end
execute "symlink nodejs" do
command "ln -s #{source_dir}/node #{install_dir}"
not_if { FileTest.exists?("#{install_dir}/node") }
end
end
@cessner
Copy link

cessner commented Jul 23, 2011

I think there's a bug in your checkout logic for the tag. It looks for the source_dir existing. It does as the previous tasks creates it. The checkout of the tag fails with compile errors because it doesn't checkout the right version. Should prob just add the checkout to the "fetch nodejs from Github or change the logic for the checkout tag action.

Bad:
Checking for program g++ or c++ : /usr/bin/g++
Checking for program cpp : /usr/bin/cpp
Checking for program ar : /usr/bin/ar
Checking for program ranlib : /usr/bin/ranlib
Checking for g++ : ok

Checking for program gcc or cc : /usr/bin/gcc
Checking for gcc : ok

Checking for library dl : yes
Checking for openssl : yes
Checking for library util : yes
Checking for library rt : yes
Checking for CLOCK_MONOTONIC : yes
Checking for fdatasync(2) with c++ : yes
'configure' finished successfully (0.530s)

and the one if I do a manual git clone and configure

Good:
Checking for program g++ or c++ : /usr/bin/g++
Checking for program cpp : /usr/bin/cpp
Checking for program ar : /usr/bin/ar
Checking for program ranlib : /usr/bin/ranlib
Checking for g++ : ok

Checking for program gcc or cc : /usr/bin/gcc
Checking for gcc : ok

Checking for library dl : yes
Checking for openssl : yes
Checking for library util : yes
Checking for library rt : yes
--- libeio ---
Checking for library pthread : yes
Checking for function pthread_create : yes
Checking for function pthread_atfork : yes
Checking for futimes(2) : yes
Checking for readahead(2) : yes
Checking for fdatasync(2) : yes
Checking for pread(2) and pwrite(2) : yes
Checking for sendfile(2) : yes
Checking for sync_file_range(2) : yes
--- libev ---
Checking for header sys/inotify.h : yes
Checking for function inotify_init : yes
Checking for header sys/epoll.h : yes
Checking for function epoll_ctl : yes
Checking for header port.h : not found
Checking for header poll.h : yes
Checking for function poll : yes
Checking for header ['sys/types.h', 'sys/event.h'] : not found
Checking for header sys/queue.h : yes
Checking for function kqueue : not found
Checking for header sys/select.h : yes
Checking for function select : yes
Checking for header sys/eventfd.h : not found
Checking for SYS_clock_gettime : yes
Checking for library rt : yes
Checking for function clock_gettime : yes
Checking for function nanosleep : yes
Checking for function ceil : yes
Checking for fdatasync(2) with c++ : yes
'configure' finished successfully (2.396s)

@chris
Copy link
Author

chris commented Jul 24, 2011

cessner, thanks for the comment. I just updated the recipe to the one we currently use. It uses a bit newer (but not the very latest) Node.js version, and fixes some issues with running this if you already had Node installed. This works properly for us on Engine Yard's AppCloud stack, but may or may not elsewhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment