railsmachine 0.1.1 → 0.1.2

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/README CHANGED
@@ -1,6 +1,3 @@
1
1
  == Railsmachine
2
2
 
3
- Doc coming soon.
4
-
5
-
6
-
3
+ Coming soon.
data/Rakefile CHANGED
@@ -15,14 +15,14 @@ setup_rdoc ['README', 'LICENSE', 'COPYING', 'lib/**/*.rb', 'doc/**/*.rdoc']
15
15
  desc "Does a full compile, test run"
16
16
  task :default => [:test, :package]
17
17
 
18
- version="0.1.1"
18
+ version="0.1.2"
19
19
  name="railsmachine"
20
20
 
21
21
  setup_gem(name, version) do |spec|
22
22
  spec.summary = "The Rails Machine task library"
23
23
  spec.description = spec.summary
24
24
  spec.author="Bradley Taylor"
25
- spec.add_dependency('capistrano', '>= 1.1.0')
25
+ spec.add_dependency('capistrano', '>= 1.2.0')
26
26
  spec.add_dependency('mongrel_cluster', '>= 0.2.0')
27
27
  spec.has_rdoc = false
28
28
  spec.files += Dir.glob("bin/*")
@@ -12,16 +12,27 @@ require 'railsmachine/recipes'
12
12
  # correspond to. The deploy_to path must be the path on each machine that will
13
13
  # form the root of the application path.
14
14
 
15
+ # The name of your application. Used for directory and file names associated with
16
+ # the application.
15
17
  set :application, "<%= singular_name %>"
18
+
19
+ # Target directory for the application on the web and app servers.
16
20
  set :deploy_to, "/var/www/apps/#{application}"
21
+
22
+ # Primary domain name of your application. Used as a default for all server roles.
17
23
  set :domain, "<%= domain_name %>"
18
24
 
25
+ # Login user for ssh.
19
26
  set :user, "deploy"
27
+
28
+ # URL of your source repository.
20
29
  set :repository, "svn+ssh://#{user}@#{domain}#{deploy_to}/repos/trunk"
30
+
31
+ # Rails environment. Used by application setup tasks and migrate tasks.
21
32
  set :rails_env, "production"
22
33
 
23
34
  # Automatically symlink these directories from curent/public to shared/public.
24
- # set :app_symlinks, %w{photo, document, asset}
35
+ # set :app_symlinks, %w{photo document asset}
25
36
 
26
37
  # =============================================================================
27
38
  # ROLES
@@ -32,6 +43,7 @@ set :rails_env, "production"
32
43
  # be used to single out a specific subset of boxes in a particular role, like
33
44
  # :primary => true.
34
45
 
46
+ # Modify these values to execute tasks on a different server.
35
47
  role :web, domain
36
48
  role :app, domain
37
49
  role :db, domain, :primary => true
@@ -60,7 +72,7 @@ role :scm, domain
60
72
  # set :mongrel_port, apache_proxy_port
61
73
  # set :mongrel_address, apache_proxy_address
62
74
  # set :mongrel_environment, "production"
63
- # set :mongrel_config, "/etc/mongrel_cluster/#{application}.conf"
75
+ # set :mongrel_conf, "/etc/mongrel_cluster/#{application}.conf"
64
76
  # set :mongrel_user, user
65
77
  # set :mongrel_group, group
66
78
 
@@ -6,37 +6,58 @@ require 'railsmachine/recipes/mongrel'
6
6
  Capistrano.configuration(:must_exist).load do
7
7
  set :app_symlinks, nil
8
8
 
9
- desc "Setup servers."
9
+ desc <<-DESC
10
+ A macro task that calls setup, setup_db, setup_app, setup_symlinks, and setup_web.
11
+ Used to configure your deployment environment in one command.
12
+ DESC
10
13
  task :setup_servers do
14
+ setup
15
+ begin
11
16
  setup_db
17
+ rescue
18
+ puts "setup_db failed!"
19
+ end
12
20
  setup_app
13
21
  setup_symlinks
14
22
  setup_web
15
23
  end
16
24
 
17
- desc "Setup application server."
25
+ desc <<-DESC
26
+ A macro task that calls setup_db, setup_app, setup_symlinks, and setup_web.
27
+ Used to configure your deployment environment in one command.
28
+ DESC
18
29
  task :setup_app, :roles => :app do
19
30
  set :mongrel_environment, rails_env
20
31
  set :mongrel_port, apache_proxy_port
21
32
  set :mongrel_servers, apache_proxy_servers
33
+ set :mongrel_user, user unless mongrel_user
34
+ set :mongrel_group, mongrel_user unless mongrel_group
35
+ set_mongrel_conf
22
36
  configure_mongrel_cluster
23
37
  end
24
38
 
25
39
  desc "Restart application server."
26
40
  task :restart_app, :roles => :app do
41
+ set_mongrel_conf
27
42
  restart_mongrel_cluster
28
43
  end
29
44
 
30
45
  desc "Start application server."
31
46
  task :start_app, :roles => :app do
47
+ set_mongrel_conf
32
48
  start_mongrel_cluster
33
49
  end
34
50
 
35
51
  desc "Stop application server."
36
52
  task :stop_app, :roles => :app do
53
+ set_mongrel_conf
37
54
  stop_mongrel_cluster
38
55
  end
39
56
 
57
+ def set_mongrel_conf
58
+ set :mongrel_conf, "/etc/mongrel_cluster/#{application}.conf" unless mongrel_conf
59
+ end
60
+
40
61
  desc "Setup web server."
41
62
  task :setup_web, :roles => :web do
42
63
  set :apache_server_name, domain unless apache_server_name
@@ -70,7 +91,11 @@ Capistrano.configuration(:must_exist).load do
70
91
 
71
92
  desc "Setup source control server."
72
93
  task :setup_scm, :roles => :scm do
94
+ begin
73
95
  setup_svn
96
+ rescue
97
+ puts "setup_svn failed!"
98
+ end
74
99
  import_svn
75
100
  end
76
101
 
@@ -33,7 +33,7 @@ Capistrano.configuration(:must_exist).load do
33
33
  buffer += ssl_buffer
34
34
  end
35
35
 
36
- put buffer, "#{shared_path}/httpd.conf"
36
+ put buffer, "#{shared_path}/httpd.conf", :mode => 0444
37
37
  send(run_method, "cp #{shared_path}/httpd.conf #{apache_conf}")
38
38
  delete "#{shared_path}/httpd.conf"
39
39
  end
@@ -0,0 +1,66 @@
1
+ # Copyright 2006, Bradley Taylor, bradley@railsmachine.com
2
+ # Licensed under the GNU Lesser General Public License.
3
+
4
+ # CentOS 4.3 install for Rails Machine
5
+ # sudo -s
6
+ # yum install postgresql-client postgresql-server postgresql-devel
7
+ # chkconfig postgresql on
8
+ # service postgresql start
9
+ # gem install postgres
10
+ # su - postgres
11
+ # createuser deploy -a -d
12
+ # exit
13
+
14
+ require 'yaml'
15
+ require 'capistrano'
16
+ require 'capistrano/cli'
17
+
18
+ module PostgreSQLMethods
19
+
20
+ def createdb(db, user)
21
+ run "createdb -O #{user} #{db}"
22
+ end
23
+
24
+ def createuser(user, password)
25
+ cmd = "createuser -P -D -A -E #{user}"
26
+ run cmd do |channel, stream, data|
27
+ if data =~ /^Enter password for new user:/
28
+ channel.send_data "#{password}\n"
29
+ end
30
+ if data =~ /^Enter it again:/
31
+ channel.send_data "#{password}\n"
32
+ end
33
+ end
34
+ end
35
+
36
+ def command(sql, database)
37
+ run "psql --command=\"#{sql}\" #{database}"
38
+ end
39
+
40
+ end
41
+
42
+ Capistrano.plugin :pgsql, PostgreSQLMethods
43
+
44
+ Capistrano.configuration(:must_exist).load do
45
+
46
+ desc "Create PosgreSQL database and user based on config/database.yml"
47
+ task :setup_pgsql, :roles => :db, :only => { :primary => true } do
48
+ # on_rollback {} TODO
49
+ read_config
50
+ pgsql.createuser db_user, db_password
51
+ pgsql.createdb db_name, db_user
52
+ end
53
+
54
+ desc "Setup database"
55
+ task :setup_db, :roles => :db, :only => { :primary => true } do
56
+ setup_pgsql
57
+ end
58
+
59
+ def read_config
60
+ db_config = YAML.load_file('config/database.yml')
61
+ set :db_user, db_config[rails_env]["username"]
62
+ set :db_password, db_config[rails_env]["password"]
63
+ set :db_name, db_config[rails_env]["database"]
64
+ end
65
+
66
+ end
@@ -11,7 +11,7 @@ Capistrano.configuration(:must_exist).load do
11
11
 
12
12
  desc "Import code into svn repository."
13
13
  task :import_svn do
14
- new_path = "../#{application}_machine"
14
+ new_path = Dir.pwd + "_machine"
15
15
  tags = repository.sub("trunk", "tags")
16
16
  branches = repository.sub("trunk", "branches")
17
17
  puts "Adding branches and tags"
@@ -58,6 +58,3 @@
58
58
  CustomLog logs/<%= domain %>-access_log combined
59
59
  </VirtualHost>
60
60
 
61
- <% if apache_ssl_enabled %>
62
- Include "<%= apache_ssl_config %>"
63
- <% end %>
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.11
2
+ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: railsmachine
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.1.1
7
- date: 2006-06-21 00:00:00 -04:00
6
+ version: 0.1.2
7
+ date: 2006-11-29 00:00:00 -05:00
8
8
  summary: The Rails Machine task library
9
9
  require_paths:
10
10
  - lib
@@ -25,6 +25,7 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
25
25
  platform: ruby
26
26
  signing_key:
27
27
  cert_chain:
28
+ post_install_message:
28
29
  authors:
29
30
  - Bradley Taylor
30
31
  files:
@@ -46,13 +47,13 @@ files:
46
47
  - lib/railsmachine/recipes/apache.rb
47
48
  - lib/railsmachine/recipes/mongrel.rb
48
49
  - lib/railsmachine/recipes/mysql.rb
50
+ - lib/railsmachine/recipes/pgsql.rb
49
51
  - lib/railsmachine/recipes/svn.rb
50
52
  - lib/railsmachine/recipes/templates
51
53
  - lib/railsmachine/recipes/templates/httpd-ssl.conf
52
54
  - lib/railsmachine/recipes/templates/httpd.conf
53
55
  - tools/rakehelp.rb
54
56
  - resources/defaults.yaml
55
- - resources/pound.conf
56
57
  test_files: []
57
58
 
58
59
  rdoc_options: []
@@ -73,7 +74,7 @@ dependencies:
73
74
  requirements:
74
75
  - - ">="
75
76
  - !ruby/object:Gem::Version
76
- version: 1.1.0
77
+ version: 1.2.0
77
78
  version:
78
79
  - !ruby/object:Gem::Dependency
79
80
  name: mongrel_cluster
data/resources/pound.conf DELETED
@@ -1,18 +0,0 @@
1
- User "nobody"
2
- Group "nobody"
3
-
4
- ListenHTTP
5
- Address <%= ip_address %>
6
- Port 80
7
-
8
- Service
9
- Backend
10
- Address 127.0.0.1
11
- Port 8000
12
- End
13
- Backend
14
- Address 127.0.0.1
15
- Port 8001
16
- End
17
- End
18
- End