capistrano-node-deploy 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +31 -0
- data/LICENSE.txt +20 -0
- data/README.md +71 -0
- data/Rakefile +53 -0
- data/VERSION +1 -0
- data/capistrano-node-deploy.gemspec +65 -0
- data/lib/capistrano-node-deploy.rb +1 -0
- data/lib/capistrano/node-deploy.rb +70 -0
- data/test/helper.rb +18 -0
- metadata +165 -0
data/.document
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
git (1.2.5)
|
5
|
+
jeweler (1.8.3)
|
6
|
+
bundler (~> 1.0)
|
7
|
+
git (>= 1.2.5)
|
8
|
+
rake
|
9
|
+
rdoc
|
10
|
+
json (1.6.6)
|
11
|
+
railsless-deploy (1.0.2)
|
12
|
+
rake (0.9.2.2)
|
13
|
+
rcov (1.0.0)
|
14
|
+
rdoc (3.12)
|
15
|
+
json (~> 1.4)
|
16
|
+
shoulda (3.0.1)
|
17
|
+
shoulda-context (~> 1.0.0)
|
18
|
+
shoulda-matchers (~> 1.0.0)
|
19
|
+
shoulda-context (1.0.0)
|
20
|
+
shoulda-matchers (1.0.0)
|
21
|
+
|
22
|
+
PLATFORMS
|
23
|
+
ruby
|
24
|
+
|
25
|
+
DEPENDENCIES
|
26
|
+
bundler (~> 1.1)
|
27
|
+
jeweler (~> 1.8.3)
|
28
|
+
railsless-deploy (~> 1.0.2)
|
29
|
+
rcov
|
30
|
+
rdoc (~> 3.12)
|
31
|
+
shoulda
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 James Smith
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
capistrano-node-deploy
|
2
|
+
======================
|
3
|
+
|
4
|
+
Capistrano recipe for deploying node.js apps.
|
5
|
+
|
6
|
+
Features
|
7
|
+
--------
|
8
|
+
- Provides `cap deploy` functionality for your node app
|
9
|
+
- Installs node packages (`npm install`) during deploys, using a shared folder for speed
|
10
|
+
- Automatically creates upstart scripts for your node apps
|
11
|
+
- Provides tasks for starting (`cap node:start`) and stopping (`cap node:stop`) your node app
|
12
|
+
|
13
|
+
|
14
|
+
Usage
|
15
|
+
-----
|
16
|
+
|
17
|
+
First install the gem:
|
18
|
+
|
19
|
+
sudo gem install capistrano-node-deploy
|
20
|
+
|
21
|
+
or add it to your `Gemfile` if you have one:
|
22
|
+
|
23
|
+
gem "capistrano-rails-deploy", "~> 1.0.0"
|
24
|
+
|
25
|
+
Now add the following to your `Capfile`
|
26
|
+
|
27
|
+
require "capistrano/node-deploy"
|
28
|
+
|
29
|
+
|
30
|
+
Full Capfile Example
|
31
|
+
--------------------
|
32
|
+
|
33
|
+
require "capistrano/node-deploy"
|
34
|
+
|
35
|
+
set :application, "my-node-app-name"
|
36
|
+
set :repository, "git@github.com:/loopj/my-node-app-name"
|
37
|
+
set :user, "deploy"
|
38
|
+
set :scm, :git
|
39
|
+
set :deploy_to, "/var/apps/my-app-folder"
|
40
|
+
|
41
|
+
role :app, "myserver.com"
|
42
|
+
|
43
|
+
|
44
|
+
Overriding Default Settings
|
45
|
+
---------------------------
|
46
|
+
|
47
|
+
# Override your node binary path
|
48
|
+
set :node_binary, "/usr/bin/coffee"
|
49
|
+
|
50
|
+
# Override your app command
|
51
|
+
set :app_command, "index.coffee --environment production"
|
52
|
+
|
53
|
+
|
54
|
+
Contributing to capistrano-node-deploy
|
55
|
+
--------------------------------------
|
56
|
+
|
57
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
58
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
59
|
+
* Fork the project.
|
60
|
+
* Start a feature/bugfix branch.
|
61
|
+
* Commit and push until you are happy with your contribution.
|
62
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
63
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
64
|
+
|
65
|
+
|
66
|
+
Copyright
|
67
|
+
---------
|
68
|
+
|
69
|
+
Copyright (c) 2012 James Smith. See LICENSE.txt for
|
70
|
+
further details.
|
71
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "capistrano-node-deploy"
|
18
|
+
gem.homepage = "http://github.com/loopj/capistrano-node-deploy"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Capistrano recipes for deploying node apps}
|
21
|
+
gem.description = %Q{Capistrano recipes for deploying node apps}
|
22
|
+
gem.email = "james@loopj.com"
|
23
|
+
gem.authors = ["James Smith"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
30
|
+
test.libs << 'lib' << 'test'
|
31
|
+
test.pattern = 'test/**/test_*.rb'
|
32
|
+
test.verbose = true
|
33
|
+
end
|
34
|
+
|
35
|
+
require 'rcov/rcovtask'
|
36
|
+
Rcov::RcovTask.new do |test|
|
37
|
+
test.libs << 'test'
|
38
|
+
test.pattern = 'test/**/test_*.rb'
|
39
|
+
test.verbose = true
|
40
|
+
test.rcov_opts << '--exclude "gems/*"'
|
41
|
+
end
|
42
|
+
|
43
|
+
task :default => :test
|
44
|
+
|
45
|
+
require 'rdoc/task'
|
46
|
+
Rake::RDocTask.new do |rdoc|
|
47
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
48
|
+
|
49
|
+
rdoc.rdoc_dir = 'rdoc'
|
50
|
+
rdoc.title = "capistrano-node-deploy #{version}"
|
51
|
+
rdoc.rdoc_files.include('README*')
|
52
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
53
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.0
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "capistrano-node-deploy"
|
8
|
+
s.version = "1.0.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["James Smith"]
|
12
|
+
s.date = "2012-06-10"
|
13
|
+
s.description = "Capistrano recipes for deploying node apps"
|
14
|
+
s.email = "james@loopj.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.md"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
"Gemfile",
|
22
|
+
"Gemfile.lock",
|
23
|
+
"LICENSE.txt",
|
24
|
+
"README.md",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"capistrano-node-deploy.gemspec",
|
28
|
+
"lib/capistrano-node-deploy.rb",
|
29
|
+
"lib/capistrano/node-deploy.rb",
|
30
|
+
"test/helper.rb"
|
31
|
+
]
|
32
|
+
s.homepage = "http://github.com/loopj/capistrano-node-deploy"
|
33
|
+
s.licenses = ["MIT"]
|
34
|
+
s.require_paths = ["lib"]
|
35
|
+
s.rubygems_version = "1.8.15"
|
36
|
+
s.summary = "Capistrano recipes for deploying node apps"
|
37
|
+
|
38
|
+
if s.respond_to? :specification_version then
|
39
|
+
s.specification_version = 3
|
40
|
+
|
41
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
42
|
+
s.add_runtime_dependency(%q<railsless-deploy>, ["~> 1.0.2"])
|
43
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
44
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
45
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.1"])
|
46
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
|
47
|
+
s.add_development_dependency(%q<rcov>, [">= 0"])
|
48
|
+
else
|
49
|
+
s.add_dependency(%q<railsless-deploy>, ["~> 1.0.2"])
|
50
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
51
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
52
|
+
s.add_dependency(%q<bundler>, ["~> 1.1"])
|
53
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
54
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
55
|
+
end
|
56
|
+
else
|
57
|
+
s.add_dependency(%q<railsless-deploy>, ["~> 1.0.2"])
|
58
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
59
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
60
|
+
s.add_dependency(%q<bundler>, ["~> 1.1"])
|
61
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
62
|
+
s.add_dependency(%q<rcov>, [">= 0"])
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
# Nothing here, see lib/capistrano/node-deploy.rb
|
@@ -0,0 +1,70 @@
|
|
1
|
+
require "railsless-deploy"
|
2
|
+
|
3
|
+
UPSTART_TEMPLATE = <<EOD
|
4
|
+
#!upstart
|
5
|
+
description "{{application}} node app"
|
6
|
+
author "capistrano"
|
7
|
+
|
8
|
+
start on startup
|
9
|
+
stop on shutdown
|
10
|
+
|
11
|
+
respawn
|
12
|
+
respawn limit 99 5
|
13
|
+
|
14
|
+
script
|
15
|
+
exec sudo -u {{user}} {{node_binary}} {{current_path}}/{{app_command}} 2>&1 >> {{shared_path}}/{{application}}.log
|
16
|
+
end script
|
17
|
+
EOD
|
18
|
+
|
19
|
+
def remote_file_exists?(full_path)
|
20
|
+
'true' == capture("if [ -e #{full_path} ]; then echo 'true'; fi").strip
|
21
|
+
end
|
22
|
+
|
23
|
+
Capistrano::Configuration.instance(:must_exist).load do |configuration|
|
24
|
+
before "deploy", "node:create_upstart_config"
|
25
|
+
after "deploy:symlink", "node:install_packages"
|
26
|
+
after "deploy:symlink", "node:restart"
|
27
|
+
|
28
|
+
set :node_binary, "/usr/bin/node" unless defined? node_binary
|
29
|
+
set :app_command, "index.js" unless defined? app_command
|
30
|
+
|
31
|
+
namespace :node do
|
32
|
+
desc "Check required packages and install if packages are not installed"
|
33
|
+
task :install_packages do
|
34
|
+
run "mkdir -p #{shared_path}/node_modules"
|
35
|
+
run "cp #{current_path}/package.json #{shared_path}"
|
36
|
+
run "cd #{shared_path}/node_modules && npm install"
|
37
|
+
run "ln -s #{shared_path}/node_modules #{current_path}/node_modules"
|
38
|
+
end
|
39
|
+
|
40
|
+
desc "Create upstart script for this node app"
|
41
|
+
task :create_upstart_config do
|
42
|
+
config_file_path = "/etc/init/#{application}.conf"
|
43
|
+
unless remote_file_exists?(config_file_path)
|
44
|
+
temp_config_file_path = "#{shared_path}/#{application}.conf"
|
45
|
+
|
46
|
+
# Generate and upload the upstart script
|
47
|
+
put UPSTART_TEMPLATE.gsub(/\{\{(.*?)\}\}/) { eval($1) }, temp_config_file_path
|
48
|
+
|
49
|
+
# Copy the script into place and make executable
|
50
|
+
sudo "cp #{temp_config_file_path} #{config_file_path}"
|
51
|
+
sudo "chmod +x #{config_file_path}"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
desc "Start the node application"
|
56
|
+
task :start do
|
57
|
+
sudo "start #{application}"
|
58
|
+
end
|
59
|
+
|
60
|
+
desc "Stop the node application"
|
61
|
+
task :stop do
|
62
|
+
sudo "stop #{application}"
|
63
|
+
end
|
64
|
+
|
65
|
+
desc "Restart the node application"
|
66
|
+
task :restart do
|
67
|
+
sudo "restart #{application}"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
require 'shoulda'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
+
require 'capistrano-node-deploy'
|
16
|
+
|
17
|
+
class Test::Unit::TestCase
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,165 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-node-deploy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 1.0.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- James Smith
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-06-10 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ~>
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
hash: 19
|
28
|
+
segments:
|
29
|
+
- 1
|
30
|
+
- 0
|
31
|
+
- 2
|
32
|
+
version: 1.0.2
|
33
|
+
requirement: *id001
|
34
|
+
type: :runtime
|
35
|
+
name: railsless-deploy
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
requirement: *id002
|
48
|
+
type: :development
|
49
|
+
name: shoulda
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ~>
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 31
|
58
|
+
segments:
|
59
|
+
- 3
|
60
|
+
- 12
|
61
|
+
version: "3.12"
|
62
|
+
requirement: *id003
|
63
|
+
type: :development
|
64
|
+
name: rdoc
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
prerelease: false
|
67
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ~>
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
hash: 13
|
73
|
+
segments:
|
74
|
+
- 1
|
75
|
+
- 1
|
76
|
+
version: "1.1"
|
77
|
+
requirement: *id004
|
78
|
+
type: :development
|
79
|
+
name: bundler
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
prerelease: false
|
82
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ~>
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
hash: 49
|
88
|
+
segments:
|
89
|
+
- 1
|
90
|
+
- 8
|
91
|
+
- 3
|
92
|
+
version: 1.8.3
|
93
|
+
requirement: *id005
|
94
|
+
type: :development
|
95
|
+
name: jeweler
|
96
|
+
- !ruby/object:Gem::Dependency
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
hash: 3
|
104
|
+
segments:
|
105
|
+
- 0
|
106
|
+
version: "0"
|
107
|
+
requirement: *id006
|
108
|
+
type: :development
|
109
|
+
name: rcov
|
110
|
+
description: Capistrano recipes for deploying node apps
|
111
|
+
email: james@loopj.com
|
112
|
+
executables: []
|
113
|
+
|
114
|
+
extensions: []
|
115
|
+
|
116
|
+
extra_rdoc_files:
|
117
|
+
- LICENSE.txt
|
118
|
+
- README.md
|
119
|
+
files:
|
120
|
+
- .document
|
121
|
+
- Gemfile
|
122
|
+
- Gemfile.lock
|
123
|
+
- LICENSE.txt
|
124
|
+
- README.md
|
125
|
+
- Rakefile
|
126
|
+
- VERSION
|
127
|
+
- capistrano-node-deploy.gemspec
|
128
|
+
- lib/capistrano-node-deploy.rb
|
129
|
+
- lib/capistrano/node-deploy.rb
|
130
|
+
- test/helper.rb
|
131
|
+
homepage: http://github.com/loopj/capistrano-node-deploy
|
132
|
+
licenses:
|
133
|
+
- MIT
|
134
|
+
post_install_message:
|
135
|
+
rdoc_options: []
|
136
|
+
|
137
|
+
require_paths:
|
138
|
+
- lib
|
139
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
140
|
+
none: false
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
hash: 3
|
145
|
+
segments:
|
146
|
+
- 0
|
147
|
+
version: "0"
|
148
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
|
+
none: false
|
150
|
+
requirements:
|
151
|
+
- - ">="
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
hash: 3
|
154
|
+
segments:
|
155
|
+
- 0
|
156
|
+
version: "0"
|
157
|
+
requirements: []
|
158
|
+
|
159
|
+
rubyforge_project:
|
160
|
+
rubygems_version: 1.8.15
|
161
|
+
signing_key:
|
162
|
+
specification_version: 3
|
163
|
+
summary: Capistrano recipes for deploying node apps
|
164
|
+
test_files: []
|
165
|
+
|