capistrano-node-deploy 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.1
1
+ 1.2.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "capistrano-node-deploy"
8
- s.version = "1.2.1"
8
+ s.version = "1.2.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["James Smith"]
12
- s.date = "2012-12-31"
12
+ s.date = "2013-02-27"
13
13
  s.description = "Capistrano recipes for deploying node apps"
14
14
  s.email = "james@loopj.com"
15
15
  s.extra_rdoc_files = [
@@ -2,22 +2,6 @@ require "digest/md5"
2
2
  require "railsless-deploy"
3
3
  require "multi_json"
4
4
 
5
- UPSTART_TEMPLATE = <<EOD
6
- #!upstart
7
- description "{{application}} node app"
8
- author "capistrano"
9
-
10
- start on (filesystem and net-device-up IFACE=lo)
11
- stop on shutdown
12
-
13
- respawn
14
- respawn limit 99 5
15
-
16
- script
17
- cd {{current_path}} && exec sudo -u {{node_user}} NODE_ENV={{node_env}} {{app_environment}} {{node_binary}} {{current_path}}/{{app_command}} 2>> {{shared_path}}/{{node_env}}.err.log 1>> {{shared_path}}/{{node_env}}.out.log
18
- end script
19
- EOD
20
-
21
5
  def remote_file_exists?(full_path)
22
6
  'true' == capture("if [ -e #{full_path} ]; then echo 'true'; fi").strip
23
7
  end
@@ -31,10 +15,6 @@ def remote_file_differs?(full_path, content)
31
15
  !exists || exists && !remote_file_content_same_as?(full_path, content)
32
16
  end
33
17
 
34
- def generate_upstart_config
35
- UPSTART_TEMPLATE.gsub(/\{\{(.*?)\}\}/) { eval($1) }
36
- end
37
-
38
18
  Capistrano::Configuration.instance(:must_exist).load do |configuration|
39
19
  before "deploy", "deploy:create_release_dir"
40
20
  before "deploy", "node:check_upstart_config"
@@ -43,37 +23,54 @@ Capistrano::Configuration.instance(:must_exist).load do |configuration|
43
23
 
44
24
  package_json = MultiJson.load(File.open("package.json").read) rescue {}
45
25
 
46
- set :application, package_json["name"] unless defined? application
47
- set :app_command, package_json["main"] || "index.js" unless defined? app_command
48
- set :app_environment, "" unless defined? app_environment
26
+ _cset :application, package_json["name"]
27
+ _cset :app_command, package_json["main"] || "index.js"
28
+ _cset :app_environment, ""
49
29
 
50
- set :node_binary, "/usr/bin/node" unless defined? node_binary
51
- set :node_env, "production" unless defined? node_env
52
- set :node_user, "deploy" unless defined? node_user
30
+ _cset :node_binary, "/usr/bin/node"
31
+ _cset :node_env, "production"
32
+ _cset :node_user, "deploy"
33
+
34
+ _cset(:upstart_job_name) { "#{application}-#{node_env}" }
35
+ _cset(:upstart_file_path) { "/etc/init/#{upstart_job_name}.conf" }
36
+ _cset(:upstart_file_contents) {
37
+ <<EOD
38
+ #!upstart
39
+ description "#{application} node app"
40
+ author "capistrano"
41
+
42
+ start on (filesystem and net-device-up IFACE=lo)
43
+ stop on shutdown
44
+
45
+ respawn
46
+ respawn limit 99 5
47
+
48
+ script
49
+ cd #{current_path} && exec sudo -u #{node_user} NODE_ENV=#{node_env} #{app_environment} #{node_binary} #{current_path}/#{app_command} 2>> #{shared_path}/#{node_env}.err.log 1>> #{shared_path}/#{node_env}.out.log
50
+ end script
51
+ EOD
52
+ }
53
53
 
54
- set :upstart_job_name, lambda { "#{application}-#{node_env}" } unless defined? upstart_job_name
55
- set :upstart_file_path, lambda { "/etc/init/#{upstart_job_name}.conf" } unless defined? upstart_file_path
56
54
 
57
55
  namespace :node do
58
56
  desc "Check required packages and install if packages are not installed"
59
57
  task :install_packages do
60
58
  run "mkdir -p #{shared_path}/node_modules"
61
59
  run "cp #{release_path}/package.json #{shared_path}"
62
- run "cd #{shared_path} && npm install #{(node_env == 'production') ? '--production' : ''}"
60
+ run "cd #{shared_path} && npm install #{(node_env == 'production') ? '--production' : ''} --loglevel warn"
63
61
  run "ln -s #{shared_path}/node_modules #{release_path}/node_modules"
64
62
  end
65
63
 
66
64
  task :check_upstart_config do
67
- create_upstart_config if remote_file_differs?(upstart_file_path, generate_upstart_config)
65
+ create_upstart_config if remote_file_differs?(upstart_file_path, upstart_file_contents)
68
66
  end
69
67
 
70
68
  desc "Create upstart script for this node app"
71
69
  task :create_upstart_config do
72
- config_file_path = "/etc/init/#{application}.conf"
73
70
  temp_config_file_path = "#{shared_path}/#{application}.conf"
74
71
 
75
72
  # Generate and upload the upstart script
76
- put generate_upstart_config, temp_config_file_path
73
+ put upstart_file_contents, temp_config_file_path
77
74
 
78
75
  # Copy the script into place and make executable
79
76
  sudo "cp #{temp_config_file_path} #{upstart_file_path}"
@@ -103,4 +100,4 @@ Capistrano::Configuration.instance(:must_exist).load do |configuration|
103
100
  run mkdir_commands.unshift(mkdir_releases).join(" && ")
104
101
  end
105
102
  end
106
- end
103
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-node-deploy
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 1
10
- version: 1.2.1
9
+ - 2
10
+ version: 1.2.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - James Smith
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-12-31 00:00:00 Z
18
+ date: 2013-02-27 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  requirement: &id001 !ruby/object:Gem::Requirement
@@ -29,10 +29,10 @@ dependencies:
29
29
  - 0
30
30
  - 2
31
31
  version: 1.0.2
32
+ type: :runtime
32
33
  version_requirements: *id001
33
34
  name: railsless-deploy
34
35
  prerelease: false
35
- type: :runtime
36
36
  - !ruby/object:Gem::Dependency
37
37
  requirement: &id002 !ruby/object:Gem::Requirement
38
38
  none: false
@@ -45,10 +45,10 @@ dependencies:
45
45
  - 3
46
46
  - 6
47
47
  version: 1.3.6
48
+ type: :runtime
48
49
  version_requirements: *id002
49
50
  name: multi_json
50
51
  prerelease: false
51
- type: :runtime
52
52
  - !ruby/object:Gem::Dependency
53
53
  requirement: &id003 !ruby/object:Gem::Requirement
54
54
  none: false
@@ -59,10 +59,10 @@ dependencies:
59
59
  segments:
60
60
  - 0
61
61
  version: "0"
62
+ type: :development
62
63
  version_requirements: *id003
63
64
  name: shoulda
64
65
  prerelease: false
65
- type: :development
66
66
  - !ruby/object:Gem::Dependency
67
67
  requirement: &id004 !ruby/object:Gem::Requirement
68
68
  none: false
@@ -74,10 +74,10 @@ dependencies:
74
74
  - 3
75
75
  - 12
76
76
  version: "3.12"
77
+ type: :development
77
78
  version_requirements: *id004
78
79
  name: rdoc
79
80
  prerelease: false
80
- type: :development
81
81
  - !ruby/object:Gem::Dependency
82
82
  requirement: &id005 !ruby/object:Gem::Requirement
83
83
  none: false
@@ -89,10 +89,10 @@ dependencies:
89
89
  - 1
90
90
  - 1
91
91
  version: "1.1"
92
+ type: :development
92
93
  version_requirements: *id005
93
94
  name: bundler
94
95
  prerelease: false
95
- type: :development
96
96
  - !ruby/object:Gem::Dependency
97
97
  requirement: &id006 !ruby/object:Gem::Requirement
98
98
  none: false
@@ -105,10 +105,10 @@ dependencies:
105
105
  - 8
106
106
  - 3
107
107
  version: 1.8.3
108
+ type: :development
108
109
  version_requirements: *id006
109
110
  name: jeweler
110
111
  prerelease: false
111
- type: :development
112
112
  - !ruby/object:Gem::Dependency
113
113
  requirement: &id007 !ruby/object:Gem::Requirement
114
114
  none: false
@@ -119,10 +119,10 @@ dependencies:
119
119
  segments:
120
120
  - 0
121
121
  version: "0"
122
+ type: :development
122
123
  version_requirements: *id007
123
124
  name: rcov
124
125
  prerelease: false
125
- type: :development
126
126
  description: Capistrano recipes for deploying node apps
127
127
  email: james@loopj.com
128
128
  executables: []