railsmachine-railsmachine 1.0.3

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.
@@ -0,0 +1,64 @@
1
+ <VirtualHost <%= apache_ssl_enabled ? apache_ssl_ip : "*" %>:80>
2
+ ServerName <%= apache_server_name %>
3
+ <% apache_server_aliases_array.each do |a| %>
4
+ ServerAlias <%= "#{a}" %>
5
+ <% end %>
6
+
7
+ <IfModule passenger_module>
8
+ RailsAutoDetect off
9
+ </IfModule>
10
+
11
+
12
+ DocumentRoot <%= "#{current_path}/public" %>
13
+
14
+ <Directory <%= "#{current_path}/public" %>>
15
+ Options FollowSymLinks
16
+ AllowOverride None
17
+ Order allow,deny
18
+ Allow from all
19
+ </Directory>
20
+
21
+ # Configure mongrel_cluster
22
+ <Proxy balancer://<%= "#{application}_cluster" %>>
23
+ <% start_port = apache_proxy_port %>
24
+ <% end_port = apache_proxy_port + apache_proxy_servers - 1 %>
25
+ <% start_port.upto(end_port) do |port| %>
26
+ BalancerMember http://<%= "#{ apache_proxy_address}:#{port.to_s}" %>
27
+ <% end %>
28
+ </Proxy>
29
+
30
+ RewriteEngine On
31
+
32
+ <% if apache_ssl_enabled && apache_ssl_forward_all %>
33
+ RewriteRule ^(.*)$ https://<%= domain %>$1
34
+ <% end %>
35
+
36
+ # Prevent access to .svn directories
37
+ RewriteRule ^(.*/)?\.svn/ - [F,L]
38
+ ErrorDocument 403 "Access Forbidden"
39
+
40
+ # Check for maintenance file and redirect all requests
41
+ RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
42
+ RewriteCond %{SCRIPT_FILENAME} !maintenance.html
43
+ RewriteRule ^.*$ /system/maintenance.html [L]
44
+
45
+ # Rewrite index to check for static
46
+ RewriteRule ^/$ /index.html [QSA]
47
+
48
+ # Rewrite to check for Rails cached page
49
+ RewriteRule ^([^.]+)$ $1.html [QSA]
50
+
51
+ # Redirect all non-static requests to cluster
52
+ RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
53
+ RewriteRule ^/(.*)$ balancer://<%= "#{application}_cluster" %>%{REQUEST_URI} [P,QSA,L]
54
+
55
+ # Deflate
56
+ AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript
57
+ BrowserMatch ^Mozilla/4 gzip-only-text/html
58
+ BrowserMatch ^Mozilla/4\.0[678] no-gzip
59
+ BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
60
+
61
+ ErrorLog logs/<%= domain %>-error_log
62
+ CustomLog logs/<%= domain %>-access_log combined
63
+ </VirtualHost>
64
+
@@ -0,0 +1,60 @@
1
+ <VirtualHost <%= apache_ssl_ip %>:443>
2
+ ServerName <%= apache_server_name %>
3
+ <% apache_server_aliases_array.each do |a| %>
4
+ ServerAlias <%= "#{a}" %>
5
+ <% end %>
6
+ DocumentRoot <%= "#{current_path}/public" %>
7
+
8
+ <Directory <%= "#{current_path}/public" %>>
9
+ Options FollowSymLinks
10
+ AllowOverride None
11
+ Order allow,deny
12
+ Allow from all
13
+ </Directory>
14
+
15
+ # set the environment
16
+ RailsEnv <%= rails_env.to_s %>
17
+
18
+ <% if use_mod_rewrite %>
19
+ RailsAllowModRewrite on
20
+ RewriteEngine On
21
+
22
+ # Prevent access to .svn directories
23
+ RewriteRule ^(.*/)?\.svn/ - [F,L]
24
+ ErrorDocument 403 "Access Forbidden"
25
+
26
+ # Check for maintenance file and redirect all requests
27
+ RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
28
+ RewriteCond %{SCRIPT_FILENAME} !maintenance.html
29
+ RewriteRule ^.*$ /system/maintenance.html [L]
30
+
31
+ <% end %>
32
+
33
+ # Deflate
34
+ AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript
35
+ BrowserMatch ^Mozilla/4 gzip-only-text/html
36
+ BrowserMatch ^Mozilla/4\.0[678] no-gzip
37
+ BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
38
+
39
+ # SSL Engine Switch
40
+ SSLEngine on
41
+
42
+ # SSL Cipher Suite:
43
+ SSLProtocol -all +SSLv3
44
+ SSLCipherSuite SSLv3:+HIGH:+MEDIUM
45
+
46
+ # Server Certificate
47
+ SSLCertificateFile /etc/httpd/conf/ssl.crt/<%= domain %>.crt
48
+
49
+ # Server Private Key
50
+ SSLCertificateKeyFile /etc/httpd/conf/ssl.key/<%= domain %>.key
51
+
52
+ BrowserMatch ".*MSIE.*" \
53
+ nokeepalive ssl-unclean-shutdown \
54
+ downgrade-1.0 force-response-1.0
55
+
56
+ ErrorLog logs/<%= domain %>-error_log
57
+ CustomLog logs/<%= domain %>-access_log combined
58
+ CustomLog logs/<%= domain %>-ssl_log \
59
+ "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
60
+ </VirtualHost>
@@ -0,0 +1,40 @@
1
+ <VirtualHost *:80>
2
+ ServerName <%= apache_server_name %>
3
+ <% apache_server_aliases_array.each do |a| %>
4
+ ServerAlias <%= "#{a}" %>
5
+ <% end %>
6
+ DocumentRoot <%= "#{current_path}/public" %>
7
+
8
+ <Directory <%= "#{current_path}/public" %>>
9
+ Options FollowSymLinks
10
+ AllowOverride None
11
+ Order allow,deny
12
+ Allow from all
13
+ </Directory>
14
+
15
+ # set the environment
16
+ RailsEnv <%= rails_env.to_s %>
17
+
18
+ <% if use_mod_rewrite %>
19
+ RailsAllowModRewrite on
20
+ RewriteEngine On
21
+
22
+ # Prevent access to .svn directories
23
+ RewriteRule ^(.*/)?\.svn/ - [F,L]
24
+ ErrorDocument 403 "Access Forbidden"
25
+
26
+ # Check for maintenance file and redirect all requests
27
+ RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
28
+ RewriteCond %{SCRIPT_FILENAME} !maintenance.html
29
+ RewriteRule ^.*$ /system/maintenance.html [L]
30
+
31
+ <% end %>
32
+ # Deflate
33
+ AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/x-javascript
34
+ BrowserMatch ^Mozilla/4 gzip-only-text/html
35
+ BrowserMatch ^Mozilla/4\.0[678] no-gzip
36
+ BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
37
+
38
+ ErrorLog logs/<%= domain %>-error_log
39
+ CustomLog logs/<%= domain %>-access_log combined
40
+ </VirtualHost>
@@ -0,0 +1,249 @@
1
+ Capistrano::Configuration.instance(:must_exist).load do
2
+
3
+ default_run_options[:pty] = true
4
+ set :keep_releases, 3
5
+ set :app_symlinks, nil
6
+ set :scm, :subversion
7
+ set :httpd, :apache
8
+ set :app_server, :mongrel
9
+ set :db_adapter, :mysql
10
+ set :rails_env, "production"
11
+
12
+ load 'config/deploy'
13
+
14
+ set :repository do
15
+ scm = fetch(:scm)
16
+ repos_base = "#{user}@#{domain}#{deploy_to}"
17
+ if scm.to_s == 'subversion'
18
+ "svn+ssh://#{repos_base}/repos/trunk"
19
+ elsif scm.to_s == 'git'
20
+ "ssh://#{repos_base}/repos/#{application}.git"
21
+ end
22
+ end
23
+
24
+
25
+ task :validate_required_variables do
26
+ validate_option(:scm, :in => [:subversion, :git])
27
+ validate_option(:app_server, :in => [:mongrel, :passenger])
28
+ validate_option(:httpd, :in => [:apache])
29
+ validate_option(:db_adapter, :in => [:mysql, :postgresql, :sqlite3])
30
+ end
31
+
32
+ before :require_recipes, :validate_required_variables
33
+
34
+ require "railsmachine/recipes/app/deploy"
35
+ require "railsmachine/recipes/app/mongrel"
36
+ require "railsmachine/recipes/app/passenger"
37
+
38
+ # defer requires until variables have been set
39
+ task :require_recipes do
40
+ require "railsmachine/recipes/scm/#{scm}"
41
+ require "railsmachine/recipes/web/#{httpd}"
42
+ require "railsmachine/recipes/db/#{db_adapter}"
43
+ end
44
+
45
+ namespace :servers do
46
+
47
+ desc <<-DESC
48
+ A macro task that calls setup for db, app, symlinks, and web.
49
+ Used to configure your deployment environment in one command.
50
+ DESC
51
+ task :setup do
52
+ sudo "chown -R #{user}:#{user} #{deploy_to.gsub(application,'')}"
53
+ deploy.setup
54
+ begin
55
+ db.setup
56
+ rescue
57
+ puts "db:setup failed!"
58
+ end
59
+ app.setup
60
+ web.setup
61
+ end
62
+
63
+ desc <<-DESC
64
+ A macro task that restarts the application and web servers
65
+ DESC
66
+ task :restart do
67
+ app.restart
68
+ web.restart
69
+ end
70
+
71
+ end
72
+
73
+ namespace :app do
74
+
75
+ desc <<-DESC
76
+ Setup #{app_server}
77
+ DESC
78
+ task :setup, :roles => :app do
79
+ case app_server.to_s
80
+ when "mongrel"
81
+ setup_mongrel
82
+ when "passenger"
83
+ # do nothing
84
+ end
85
+ end
86
+
87
+ desc <<-DESC
88
+ Restart application server.
89
+ DESC
90
+ task :restart, :roles => :app do
91
+ application_servlet.restart
92
+ end
93
+
94
+ desc <<-DESC
95
+ Start application server.
96
+ DESC
97
+ task :start, :roles => :app do
98
+ application_servlet.start
99
+ end
100
+
101
+ desc <<-DESC
102
+ Stop application server.
103
+ DESC
104
+ task :stop, :roles => :app do
105
+ application_servlet.stop
106
+ end
107
+
108
+ desc <<-DESC
109
+ Switch your application to run on mongrel or passenger.
110
+ DESC
111
+ task :switch do
112
+ case app_server.to_s
113
+ when "mongrel"
114
+ switch_to_mongrel
115
+ when "passenger"
116
+ switch_to_passenger
117
+ end
118
+ end
119
+
120
+ namespace :symlinks do
121
+
122
+ desc <<-DESC
123
+ Setup application symlinks in the public
124
+ DESC
125
+ task :setup, :roles => [:app, :web] do
126
+ if app_symlinks
127
+ app_symlinks.each { |link| run "mkdir -p #{shared_path}/public/#{link}" }
128
+ end
129
+ end
130
+
131
+ desc <<-DESC
132
+ Link public directories to shared location.
133
+ DESC
134
+ task :update, :roles => [:app, :web] do
135
+ if app_symlinks
136
+ app_symlinks.each { |link| run "ln -nfs #{shared_path}/public/#{link} #{current_path}/public/#{link}" }
137
+ end
138
+ end
139
+
140
+ end
141
+
142
+ end
143
+
144
+ namespace :web do
145
+
146
+ desc <<-DESC
147
+ Setup web server.
148
+ DESC
149
+ task :setup, :roles => :web do
150
+ set :apache_server_name, domain unless apache_server_name
151
+ apache.configure
152
+ end
153
+
154
+ desc <<-DESC
155
+ Restart web server.
156
+ DESC
157
+ task :restart, :roles => :web do
158
+ apache.restart
159
+ end
160
+
161
+ desc <<-DESC
162
+ Reload web server configuration.
163
+ DESC
164
+ task :reload, :roles => :web do
165
+ apache.reload
166
+ end
167
+
168
+ desc <<-DESC
169
+ Start web server.
170
+ DESC
171
+ task :start, :roles => :web do
172
+ apache.start
173
+ end
174
+
175
+ desc <<-DESC
176
+ Stop web server.
177
+ DESC
178
+ task :stop, :roles => :web do
179
+ apache.stop
180
+ end
181
+
182
+ end
183
+
184
+ namespace :repos do
185
+ desc <<-DESC
186
+ Setup source control repository.
187
+ DESC
188
+ task :setup, :roles => :scm do
189
+ begin
190
+ sudo "chown -R #{user}:#{user} #{deploy_to.gsub(application,'')}"
191
+ localrepo.setup
192
+ rescue
193
+ puts "repos:setup failed!"
194
+ end
195
+ localrepo.import
196
+ end
197
+
198
+ end
199
+
200
+ on :start, :require_recipes
201
+ before 'deploy:update_code', 'app:symlinks:setup'
202
+ after 'deploy:symlink', 'app:symlinks:update'
203
+ after 'deploy:cold', 'web:reload'
204
+ after :deploy,'deploy:cleanup'
205
+
206
+ def setup_mongrel
207
+ set_mongrel_conf
208
+ set :mongrel_environment, rails_env
209
+ set :mongrel_port, apache_proxy_port
210
+ set :mongrel_servers, apache_proxy_servers
211
+ set :mongrel_user, user unless mongrel_user
212
+ set :mongrel_group, mongrel_user unless mongrel_group
213
+ mongrel.cluster.configure
214
+ end
215
+
216
+ def switch_to_mongrel
217
+ app.setup
218
+ app.start
219
+ web.setup
220
+ web.restart
221
+ end
222
+
223
+ def switch_to_passenger
224
+ web.setup
225
+ mongrel.cluster.remove
226
+ web.restart
227
+ end
228
+
229
+ def validate_option(key, options = {})
230
+ if !(options[:in].map{|o| o.to_s } + ['']).include?(self[key].to_s)
231
+ raise(ArgumentError, error_msg("Invalid value '#{self[key]}' for option '#{key}' must be one of the following: '#{options[:in].join(', ')}'"))
232
+ end
233
+ end
234
+
235
+ def application_servlet
236
+ case app_server.to_s
237
+ when 'mongrel'
238
+ mongrel.cluster
239
+ when 'passenger'
240
+ passenger
241
+ end
242
+ end
243
+
244
+ def error_msg(msg)
245
+ banner = ''; msg.length.times { banner << "+" }
246
+ return "\n\n#{banner}\n#{msg}\n#{banner}\n\n"
247
+ end
248
+
249
+ end
@@ -0,0 +1,3 @@
1
+ ---
2
+ :debug: false
3
+
data/tools/rakehelp.rb ADDED
@@ -0,0 +1,105 @@
1
+
2
+ def make(makedir)
3
+ Dir.chdir(makedir) do
4
+ sh(PLATFORM =~ /win32/ ? 'nmake' : 'make')
5
+ end
6
+ end
7
+
8
+
9
+ def extconf(dir)
10
+ Dir.chdir(dir) do ruby "extconf.rb" end
11
+ end
12
+
13
+
14
+ def setup_tests
15
+ Rake::TestTask.new do |t|
16
+ t.libs << "test"
17
+ t.test_files = FileList['test/test*.rb']
18
+ t.verbose = true
19
+ end
20
+ end
21
+
22
+
23
+ def setup_clean otherfiles
24
+ files = ['build/*', '**/*.o', '**/*.so', '**/*.a', 'lib/*-*', '**/*.log'] + otherfiles
25
+ CLEAN.include(files)
26
+ end
27
+
28
+
29
+ def setup_rdoc files
30
+ Rake::RDocTask.new do |rdoc|
31
+ rdoc.rdoc_dir = 'doc/rdoc'
32
+ rdoc.options << '--line-numbers'
33
+ rdoc.rdoc_files.add(files)
34
+ end
35
+ end
36
+
37
+
38
+ def setup_extension(dir, extension)
39
+ ext = "ext/#{dir}"
40
+ ext_so = "#{ext}/#{extension}.#{Config::CONFIG['DLEXT']}"
41
+ ext_files = FileList[
42
+ "#{ext}/*.c",
43
+ "#{ext}/*.h",
44
+ "#{ext}/extconf.rb",
45
+ "#{ext}/Makefile",
46
+ "lib"
47
+ ]
48
+
49
+ task "lib" do
50
+ directory "lib"
51
+ end
52
+
53
+ desc "Builds just the #{extension} extension"
54
+ task extension.to_sym => ["#{ext}/Makefile", ext_so ]
55
+
56
+ file "#{ext}/Makefile" => ["#{ext}/extconf.rb"] do
57
+ extconf "#{ext}"
58
+ end
59
+
60
+ file ext_so => ext_files do
61
+ make "#{ext}"
62
+ cp ext_so, "lib"
63
+ end
64
+ end
65
+
66
+
67
+ def base_gem_spec(pkg_name, pkg_version)
68
+ pkg_version = pkg_version
69
+ pkg_name = pkg_name
70
+ pkg_file_name = "#{pkg_name}-#{pkg_version}"
71
+ Gem::Specification.new do |s|
72
+ s.name = pkg_name
73
+ s.version = pkg_version
74
+ s.platform = Gem::Platform::RUBY
75
+ s.has_rdoc = true
76
+ s.extra_rdoc_files = [ "README" ]
77
+
78
+ s.files = %w(COPYING LICENSE README Rakefile) +
79
+ Dir.glob("{bin,doc/rdoc,test,lib}/**/*") +
80
+ Dir.glob("ext/**/*.{h,c,rb}") +
81
+ Dir.glob("examples/**/*.rb") +
82
+ Dir.glob("tools/*.rb")
83
+
84
+ s.require_path = "lib"
85
+ s.extensions = FileList["ext/**/extconf.rb"].to_a
86
+ s.bindir = "bin"
87
+ end
88
+ end
89
+
90
+ def setup_gem(pkg_name, pkg_version)
91
+ spec = base_gem_spec(pkg_name, pkg_version)
92
+ yield spec if block_given?
93
+
94
+ Rake::GemPackageTask.new(spec) do |p|
95
+ p.gem_spec = spec
96
+ p.need_tar = true
97
+ end
98
+ end
99
+
100
+ def setup_win32_gem(pkg_name, pkg_version)
101
+ spec = base_gem_spec(pkg_name, pkg_version)
102
+ yield spec if block_given?
103
+
104
+ Gem::Builder.new(spec).build
105
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: railsmachine-railsmachine
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Rails Machine
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-12-18 00:00:00 -08:00
13
+ default_executable: railsmachine
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: capistrano
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 2.1.0
23
+ version:
24
+ description: The Rails Machine task library
25
+ email: support@railsmachine.com
26
+ executables:
27
+ - railsmachine
28
+ extensions: []
29
+
30
+ extra_rdoc_files: []
31
+
32
+ files:
33
+ - bin/railsmachine
34
+ - lib/railsmachine
35
+ - lib/railsmachine/generators/loader.rb
36
+ - lib/railsmachine/generators/railsmachine
37
+ - lib/railsmachine/generators/railsmachine/railsmachine_generator.rb
38
+ - lib/railsmachine/generators/railsmachine/templates
39
+ - lib/railsmachine/generators/railsmachine/templates/deploy.rb
40
+ - lib/railsmachine/generators/railsmachine/USAGE
41
+ - lib/railsmachine/recipes/app/deploy.rb
42
+ - lib/railsmachine/recipes/app/mongrel.rb
43
+ - lib/railsmachine/recipes/app/passenger.rb
44
+ - lib/railsmachine/recipes/db/mysql.rb
45
+ - lib/railsmachine/recipes/db/postgresql.rb
46
+ - lib/railsmachine/recipes/db/sqlite3.rb
47
+ - lib/railsmachine/recipes/scm/git.rb
48
+ - lib/railsmachine/recipes/scm/subversion.rb
49
+ - lib/railsmachine/recipes/web/apache.rb
50
+ - lib/railsmachine/recipes/web/templates
51
+ - lib/railsmachine/recipes/web/templates/mongrel/httpd-ssl.conf
52
+ - lib/railsmachine/recipes/web/templates/mongrel/httpd.conf
53
+ - lib/railsmachine/recipes/web/templates/passenger/httpd-ssl.conf
54
+ - lib/railsmachine/recipes/web/templates/passenger/httpd.conf
55
+ - lib/railsmachine/recipes.rb
56
+ - resources/defaults.yaml
57
+ - tools/rakehelp.rb
58
+ - README.textile
59
+ - LICENSE
60
+ - COPYING
61
+ has_rdoc: false
62
+ homepage: http://railsmachine.com/
63
+ post_install_message:
64
+ rdoc_options: []
65
+
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: "0"
73
+ version:
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: "0"
79
+ version:
80
+ requirements: []
81
+
82
+ rubyforge_project: railsmachine
83
+ rubygems_version: 1.2.0
84
+ signing_key:
85
+ specification_version: 2
86
+ summary: The Rails Machine task library
87
+ test_files: []
88
+