lib/capistrano/node-deploy.rb in capistrano-node-deploy-1.0.5 vs lib/capistrano/node-deploy.rb in capistrano-node-deploy-1.0.6
- old
+ new
@@ -21,11 +21,11 @@
'true' == capture("if [ -e #{full_path} ]; then echo 'true'; fi").strip
end
Capistrano::Configuration.instance(:must_exist).load do |configuration|
before "deploy", "deploy:create_release_dir"
- before "deploy", "node:create_upstart_config"
+ before "deploy", "node:check_upstart_config"
after "deploy:symlink", "node:install_packages"
after "deploy:symlink", "node:restart"
package_json = MultiJson.load(File.open("package.json").read) rescue {}
@@ -40,22 +40,24 @@
run "cp #{current_path}/package.json #{shared_path}"
run "cd #{shared_path} && npm install"
run "ln -s #{shared_path}/node_modules #{current_path}/node_modules"
end
+ task :check_upstart_config do
+ create_upstart_config unless remote_file_exists?("/etc/init/#{application}.conf")
+ end
+
desc "Create upstart script for this node app"
task :create_upstart_config do
config_file_path = "/etc/init/#{application}.conf"
- unless remote_file_exists?(config_file_path)
- temp_config_file_path = "#{shared_path}/#{application}.conf"
+ temp_config_file_path = "#{shared_path}/#{application}.conf"
- # Generate and upload the upstart script
- put UPSTART_TEMPLATE.gsub(/\{\{(.*?)\}\}/) { eval($1) }, temp_config_file_path
+ # Generate and upload the upstart script
+ put UPSTART_TEMPLATE.gsub(/\{\{(.*?)\}\}/) { eval($1) }, temp_config_file_path
- # Copy the script into place and make executable
- sudo "cp #{temp_config_file_path} #{config_file_path}"
- sudo "chmod +x #{config_file_path}"
- end
+ # Copy the script into place and make executable
+ sudo "cp #{temp_config_file_path} #{config_file_path}"
+ sudo "chmod +x #{config_file_path}"
end
desc "Start the node application"
task :start do
sudo "start #{application}"
\ No newline at end of file