vlad-unicorn 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.autotest ADDED
@@ -0,0 +1,23 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'autotest/restart'
4
+
5
+ # Autotest.add_hook :initialize do |at|
6
+ # at.extra_files << "../some/external/dependency.rb"
7
+ #
8
+ # at.libs << ":../some/external"
9
+ #
10
+ # at.add_exception 'vendor'
11
+ #
12
+ # at.add_mapping(/dependency.rb/) do |f, _|
13
+ # at.files_matching(/test_.*rb$/)
14
+ # end
15
+ #
16
+ # %w(TestA TestB).each do |klass|
17
+ # at.extra_class_map[klass] = "test/test_misc.rb"
18
+ # end
19
+ # end
20
+
21
+ # Autotest.add_hook :run_command do |at|
22
+ # system "rake build"
23
+ # end
data/History.txt ADDED
@@ -0,0 +1,6 @@
1
+ === 2.0.0 / 2010-09-18
2
+
3
+ * 1 major enhancement
4
+
5
+ * Birthday!
6
+
data/Manifest.txt ADDED
@@ -0,0 +1,10 @@
1
+ .autotest
2
+ History.txt
3
+ Manifest.txt
4
+ README.txt
5
+ Rakefile
6
+ docs/rails-configuration.txt
7
+ lib/vlad/unicorn.rb
8
+ lib/vlad/unicorn_common.rb
9
+ lib/vlad/unicorn_rails.rb
10
+ test/test_vlad_unicorn.rb
data/README.txt ADDED
@@ -0,0 +1,85 @@
1
+ = vlad-unicorn
2
+
3
+ * http://bitbucket.org/krbullock/vlad-unicorn/
4
+
5
+ == DESCRIPTION:
6
+
7
+ Unicorn app server support for Vlad. Adds support for vlad:start_app and
8
+ vlad:stop_app using Unicorn[http://unicorn.bogomips.org/].
9
+
10
+ == FEATURES/PROBLEMS:
11
+
12
+ * Unicorn support for vlad:start_app and vlad:stop_app tasks.
13
+
14
+ == SYNOPSIS:
15
+
16
+ # lib/tasks/vlad.rake
17
+ begin
18
+ require 'vlad'
19
+ Vlad.load(:app => :unicorn)
20
+ rescue LoadError
21
+ end
22
+
23
+ or for legacy Rails (1.2.x thru 2.2.x) apps
24
+
25
+ # lib/tasks/vlad.rake
26
+ begin
27
+ require 'vlad'
28
+ Vlad.load(:app => :unicorn_rails)
29
+ rescue LoadError
30
+ end
31
+
32
+ == REQUIREMENTS:
33
+
34
+ * Vlad[http://rubyhitsquad.com/Vlad_the_Deployer.html]
35
+
36
+ * Unicorn[http://unicorn.bogomips.org/]
37
+
38
+ == INSTALL:
39
+
40
+ $ sudo gem install vlad-unicorn
41
+
42
+ == VARIABLES:
43
+
44
+ unicorn_command:: Defaults to 'unicorn' when using
45
+ <tt>:app => :unicorn</tt>, and 'unicorn_rails' with
46
+ <tt>:app => :unicorn_rails.</tt>
47
+ unicorn_config:: The location of the Unicorn config file. Defaults to
48
+ "#{current_path}/config/unicorn.rb".
49
+ unicorn_pid:: The location of the Unicorn pid file. Must be the same
50
+ as in unicorn.rb file. Currently needed for the
51
+ +stop_app+ task, but hopefully won't be necessary in a
52
+ future version.
53
+ unicorn_rackup:: The location of the rackup file unicorn should load.
54
+ Defaults to "#{current_path}/config.ru". Not set nor
55
+ used for +unicorn_rails+.
56
+ unicorn_use_sudo:: Whether to use sudo to run the 'unicorn' command on
57
+ the remote host. Probably necessary if you specify a
58
+ user and group in unicorn.rb.
59
+
60
+ Also see rails-configuration.txt.
61
+
62
+ == LICENSE:
63
+
64
+ (The MIT License)
65
+
66
+ Copyright (c) 2010 Kevin Bullock and the rest of the Ruby Hit Squad
67
+
68
+ Permission is hereby granted, free of charge, to any person obtaining
69
+ a copy of this software and associated documentation files (the
70
+ 'Software'), to deal in the Software without restriction, including
71
+ without limitation the rights to use, copy, modify, merge, publish,
72
+ distribute, sublicense, and/or sell copies of the Software, and to
73
+ permit persons to whom the Software is furnished to do so, subject to
74
+ the following conditions:
75
+
76
+ The above copyright notice and this permission notice shall be
77
+ included in all copies or substantial portions of the Software.
78
+
79
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
80
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
81
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
82
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
83
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
84
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
85
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+
6
+ Hoe.plugin :hg
7
+
8
+ Hoe.spec 'vlad-unicorn' do
9
+ self.rubyforge_name = 'hitsquad'
10
+ developer('Kevin R. Bullock', 'kbullock@ringworld.org')
11
+ extra_deps << ['vlad', '~> 2.0']
12
+ clean_globs << '.yardoc'
13
+ self.hg_release_tag_prefix = 'rel-'
14
+ end
15
+
16
+ # vim: syntax=ruby
@@ -0,0 +1,10 @@
1
+ = Configuring Unicorn for Rails
2
+
3
+ The astute observer will notice the lack of variables in vlad-unicorn to set
4
+ the Rails environment or a path prefix for the app (the +unicorn_rails+
5
+ command allows this with with the +--env+ and +--path+ options, respectively).
6
+ Both of these can just as easily be done by setting the appropriate
7
+ environment variables in the unicorn.rb config file, like so:
8
+
9
+ ENV['RAILS_ENV'] = 'production'
10
+ ENV['RAILS_RELATIVE_URL_ROOT'] = '/prefix'
@@ -0,0 +1,14 @@
1
+ require 'vlad/unicorn_common'
2
+
3
+ namespace :vlad do
4
+ ##
5
+ # Unicorn app server
6
+
7
+ set(:unicorn_rackup) { "#{current_path}/config.ru" }
8
+
9
+ desc "(Re)Start the app servers"
10
+ remote_task :start_app, :roles => :app do
11
+ Rake::Task['vlad:stop_app'].invoke
12
+ Vlad::Unicorn.maybe_sudo unicorn(unicorn_rackup)
13
+ end
14
+ end
@@ -0,0 +1,40 @@
1
+ require 'vlad'
2
+
3
+ module Vlad
4
+ module Unicorn
5
+ VERSION = '2.0.0' #:nodoc:
6
+
7
+ # Runs +cmd+ using sudo if the +:merb_use_sudo+ variable is set.
8
+ def self.maybe_sudo(cmd)
9
+ if unicorn_use_sudo
10
+ sudo cmd
11
+ else
12
+ run cmd
13
+ end
14
+ end
15
+ end
16
+ end
17
+
18
+ namespace :vlad do
19
+
20
+ set :unicorn_command, "unicorn"
21
+ set(:unicorn_config) { "#{current_path}/config/unicorn.rb" }
22
+ set :unicorn_use_sudo, false
23
+ set(:unicorn_pid) { "#{shared_path}/pids/unicorn.pid" }
24
+
25
+ def unicorn(opts = '')
26
+ cmd = "#{unicorn_command} -D --config-file #{unicorn_config}"
27
+ cmd << " #{opts}"
28
+ cmd
29
+ end
30
+
31
+ desc "Stop the app servers"
32
+ remote_task :stop_app, :roles => :app do
33
+ cmd = []
34
+ cmd << %(if [ -f "#{unicorn_pid}" ])
35
+ cmd << %(then kill `cat #{unicorn_pid}` || echo "stale pid file #{unicorn_pid}")
36
+ cmd << %(fi)
37
+ Vlad::Unicorn.maybe_sudo %Q(sh -c '#{cmd.join("; ")}')
38
+ end
39
+
40
+ end
@@ -0,0 +1,14 @@
1
+ require 'vlad/unicorn_common'
2
+
3
+ namespace :vlad do
4
+ ##
5
+ # Unicorn app server for legacy Rails apps
6
+
7
+ set :unicorn_command, "unicorn_rails"
8
+
9
+ desc "(Re)Start the app servers"
10
+ remote_task :start_app, :roles => :app do
11
+ Rake::Task['vlad:stop_app'].invoke
12
+ Vlad::Unicorn.maybe_sudo unicorn
13
+ end
14
+ end
@@ -0,0 +1,8 @@
1
+ require "test/unit"
2
+ require "vlad/unicorn"
3
+
4
+ class TestVladUnicorn < Test::Unit::TestCase
5
+ def test_sanity
6
+ flunk "write tests or I will kneecap you"
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,129 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vlad-unicorn
3
+ version: !ruby/object:Gem::Version
4
+ hash: 15
5
+ prerelease: false
6
+ segments:
7
+ - 2
8
+ - 0
9
+ - 0
10
+ version: 2.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Kevin R. Bullock
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-09-18 00:00:00 -05:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: vlad
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 2
32
+ - 0
33
+ version: "2.0"
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: rubyforge
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ hash: 7
45
+ segments:
46
+ - 2
47
+ - 0
48
+ - 4
49
+ version: 2.0.4
50
+ type: :development
51
+ version_requirements: *id002
52
+ - !ruby/object:Gem::Dependency
53
+ name: hoe
54
+ prerelease: false
55
+ requirement: &id003 !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ hash: 21
61
+ segments:
62
+ - 2
63
+ - 6
64
+ - 1
65
+ version: 2.6.1
66
+ type: :development
67
+ version_requirements: *id003
68
+ description: |-
69
+ Unicorn app server support for Vlad. Adds support for vlad:start_app and
70
+ vlad:stop_app using Unicorn[http://unicorn.bogomips.org/].
71
+ email:
72
+ - kbullock@ringworld.org
73
+ executables: []
74
+
75
+ extensions: []
76
+
77
+ extra_rdoc_files:
78
+ - History.txt
79
+ - Manifest.txt
80
+ - README.txt
81
+ - docs/rails-configuration.txt
82
+ files:
83
+ - .autotest
84
+ - History.txt
85
+ - Manifest.txt
86
+ - README.txt
87
+ - Rakefile
88
+ - docs/rails-configuration.txt
89
+ - lib/vlad/unicorn.rb
90
+ - lib/vlad/unicorn_common.rb
91
+ - lib/vlad/unicorn_rails.rb
92
+ - test/test_vlad_unicorn.rb
93
+ has_rdoc: true
94
+ homepage: http://bitbucket.org/krbullock/vlad-unicorn/
95
+ licenses: []
96
+
97
+ post_install_message:
98
+ rdoc_options:
99
+ - --main
100
+ - README.txt
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ none: false
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ hash: 3
109
+ segments:
110
+ - 0
111
+ version: "0"
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ hash: 3
118
+ segments:
119
+ - 0
120
+ version: "0"
121
+ requirements: []
122
+
123
+ rubyforge_project: hitsquad
124
+ rubygems_version: 1.3.7
125
+ signing_key:
126
+ specification_version: 3
127
+ summary: Unicorn app server support for Vlad
128
+ test_files:
129
+ - test/test_vlad_unicorn.rb