chrisrec 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. data/Manifest +9 -53
  2. data/README +14 -0
  3. data/Rakefile +1 -1
  4. data/chrisrec.gemspec +11 -12
  5. data/lib/chrisrec.rb +6 -11
  6. data/{lib → retired/lib}/backgroundrb/backgroundrb.rb +0 -0
  7. data/{lib → retired/lib}/gitosis/gitosis.rb +0 -0
  8. data/{lib → retired/lib}/memcached/memcached.rb +0 -0
  9. data/{lib → retired/lib}/starling/starling.rb +0 -0
  10. data/{lib → retired/lib}/workling/workling.rb +0 -0
  11. data/{pkg/chrisrec-0.1.2 → retired}/template/starling/monit.conf.erb +0 -0
  12. data/{pkg/chrisrec-0.1.2 → retired}/template/starling/starling-init-script.erb +0 -0
  13. data/{pkg/chrisrec-0.1.2 → retired}/template/workling/monit.conf.erb +0 -0
  14. data/{pkg/chrisrec-0.1.2 → retired}/template/workling/workling-init-script.erb +0 -0
  15. data/template/static/httpd-vhost-static.conf.erb +2 -2
  16. metadata +30 -100
  17. data/pkg/chrisrec-0.1.2/Manifest +0 -88
  18. data/pkg/chrisrec-0.1.2/README +0 -1
  19. data/pkg/chrisrec-0.1.2/Rakefile +0 -21
  20. data/pkg/chrisrec-0.1.2/chrisrec.gemspec +0 -30
  21. data/pkg/chrisrec-0.1.2/lib/backgroundrb/backgroundrb.rb +0 -22
  22. data/pkg/chrisrec-0.1.2/lib/chrisrec.rb +0 -14
  23. data/pkg/chrisrec-0.1.2/lib/console/console.rb +0 -19
  24. data/pkg/chrisrec-0.1.2/lib/daemon/daemon.rb +0 -134
  25. data/pkg/chrisrec-0.1.2/lib/gitosis/gitosis.rb +0 -131
  26. data/pkg/chrisrec-0.1.2/lib/jekyll/jekyll.rb +0 -87
  27. data/pkg/chrisrec-0.1.2/lib/memcached/memcached.rb +0 -140
  28. data/pkg/chrisrec-0.1.2/lib/munin/munin.rb +0 -135
  29. data/pkg/chrisrec-0.1.2/lib/mysql/mysql.rake +0 -95
  30. data/pkg/chrisrec-0.1.2/lib/mysql/mysql.rb +0 -51
  31. data/pkg/chrisrec-0.1.2/lib/rake/rake.rb +0 -19
  32. data/pkg/chrisrec-0.1.2/lib/rakecron/rakecron.rb +0 -35
  33. data/pkg/chrisrec-0.1.2/lib/starling/starling.rb +0 -124
  34. data/pkg/chrisrec-0.1.2/lib/static/static.rb +0 -80
  35. data/pkg/chrisrec-0.1.2/lib/tomcat/tomcat.rb +0 -202
  36. data/pkg/chrisrec-0.1.2/lib/workling/workling.rb +0 -72
  37. data/pkg/chrisrec-0.1.2/template/daemon/daemon-init-script.erb +0 -59
  38. data/pkg/chrisrec-0.1.2/template/daemon/monit.conf.erb +0 -4
  39. data/pkg/chrisrec-0.1.2/template/jekyll/httpd-vhost-jekyll.conf.erb +0 -16
  40. data/pkg/chrisrec-0.1.2/template/memcached/memcached-conf.erb +0 -1
  41. data/pkg/chrisrec-0.1.2/template/memcached/memcached.erb +0 -59
  42. data/pkg/chrisrec-0.1.2/template/memcached/monit.conf.erb +0 -8
  43. data/pkg/chrisrec-0.1.2/template/memcached/start-memcached.erb +0 -118
  44. data/pkg/chrisrec-0.1.2/template/munin/httpd-vhost-munin.conf.erb +0 -20
  45. data/pkg/chrisrec-0.1.2/template/munin/munin.conf.erb +0 -70
  46. data/pkg/chrisrec-0.1.2/template/munin/munin_nginx_vhost.conf.erb +0 -24
  47. data/pkg/chrisrec-0.1.2/template/rakecron/rakecron.erb +0 -12
  48. data/pkg/chrisrec-0.1.2/template/static/httpd-vhost-static.conf.erb +0 -16
  49. data/pkg/chrisrec-0.1.2/template/tomcat/conf/server.xml.erb +0 -33
  50. data/pkg/chrisrec-0.1.2/template/tomcat/conf/web.xml +0 -1194
  51. data/pkg/chrisrec-0.1.2/template/tomcat/logs/empty.txt +0 -1
  52. data/pkg/chrisrec-0.1.2/template/tomcat/monit.conf.erb +0 -8
  53. data/pkg/chrisrec-0.1.2/template/tomcat/temp/empty.txt +0 -1
  54. data/pkg/chrisrec-0.1.2/template/tomcat/tomcat.erb +0 -28
  55. data/pkg/chrisrec-0.1.2/template/tomcat/webapps/empty.txt +0 -1
  56. data/pkg/chrisrec-0.1.2/template/tomcat/work/empty.txt +0 -1
  57. data/template/starling/monit.conf.erb +0 -14
  58. data/template/starling/starling-init-script.erb +0 -69
  59. data/template/workling/monit.conf.erb +0 -4
  60. data/template/workling/workling-init-script.erb +0 -56
@@ -1,140 +0,0 @@
1
- Capistrano::Configuration.instance(:must_exist).load do
2
- namespace :chrisrec do
3
- namespace :memcached do
4
-
5
- # role :cache, 'ADDRESS TO CACHE'
6
-
7
- set :memcached_port, 11211
8
- set :memcached_address, '127.0.0.1'
9
- set :memcached_memory, 256
10
- set :memcached_user, "memcached"
11
- set :memcached_group, "memcached"
12
- set :memcached_run_dir, "/var/run"
13
- set :memcached_log_dir, "/var/log"
14
-
15
- set :local_template_dir, "#{File.dirname(__FILE__)}/../../template"
16
-
17
- desc "Install memcached"
18
- task :install, :roles => :cache do
19
- version = 'memcached-1.4.0'
20
- set :src_package, {
21
- :file => version + '.tar.gz',
22
- # :md5sum => 'a08851f7fa7b15e92ee6320b7a79c321 memcached-1.2.2.tar.gz',
23
- :dir => version,
24
- :url => "http://www.danga.com/memcached/dist/#{version}.tar.gz",
25
- :unpack => "tar zxf #{version}.tar.gz;",
26
- :configure => %w{
27
- ./configure
28
- --prefix=/usr/local
29
- ;
30
- }.reject{|arg| arg.match '#'}.join(' '),
31
- :make => 'make;',
32
- :install => 'make install;'
33
- }
34
- apt.install( {:base => %w(libevent-dev)}, :stable )
35
- deprec2.download_src(src_package, src_dir)
36
- deprec2.install_from_src(src_package, src_dir)
37
-
38
- # deprec2.mkdir(memcached_run_dir, :via => :sudo)
39
- # deprec2.mkdir(memcached_log_dir, :via => :sudo)
40
-
41
- create_memcached_user_and_group
42
- set_perms_for_memcached_dirs
43
- end
44
-
45
- # Configure
46
- SYSTEM_CONFIG_FILES[:memcached] = [
47
- {:template => 'memcached.erb',
48
- :path => 'memcached/etc/init.d/memcached',
49
- :mode => 0755,
50
- :owner => 'root:root'},
51
-
52
- {:template => 'memcached-conf.erb',
53
- :path => 'memcached/etc/init.d/memcached.conf',
54
- :mode => 0755,
55
- :owner => 'root:root'},
56
-
57
- {:template => 'start-memcached.erb',
58
- :path => 'memcached/etc/init.d/start-memcached',
59
- :mode => 0755,
60
- :owner => 'root:root'},
61
-
62
- {:template => 'monit.conf.erb',
63
- :path => "memcached/etc/monit.d/monit_memcached.conf",
64
- :mode => 0600,
65
- :owner => 'root:root'}
66
- ]
67
-
68
- # Generating Configuration Files
69
- desc "Generate configuration file(s) for memcached from template(s)"
70
- task :config_gen do
71
- SYSTEM_CONFIG_FILES[:memcached].each do |file|
72
- deprec2.render_template(:memcached, file)
73
- end
74
- end
75
-
76
- desc 'Deploy configuration files(s) for memcached'
77
- task :config, :roles => :cache do
78
-
79
- deprec2.push_configs(:memcached, SYSTEM_CONFIG_FILES[:memcached])
80
- symlink_init_d
81
- symlink_monit_d
82
-
83
- activate
84
- end
85
-
86
- desc "Stop memcached"
87
- task :stop , :roles => :cache do
88
- sudo "/etc/init.d/memcached_#{memcached_port} stop"
89
- end
90
-
91
- desc "Start memcached"
92
- task :start , :roles => :cache do
93
- sudo "/etc/init.d/memcached_#{memcached_port} start"
94
- end
95
-
96
- desc "Start the memcached server"
97
- task :restart, :roles => :cache do
98
- stop
99
- sleep(2)
100
- start
101
- end
102
-
103
- task :activate, :roles => :cache do
104
- send(run_method, "update-rc.d memcached_#{memcached_port} defaults")
105
- end
106
-
107
- task :deactivate, :roles => :cache do
108
- send(run_method, "update-rc.d -f memcached_#{memcached_port} remove")
109
- end
110
-
111
- # User/Group creation & permission assignment
112
- # These were based off the tasks used in the mongrel recipe -
113
- # as this was probably the nicest way to ensure these tasks
114
- # were doing the right thing.
115
- desc "create user and group for memcached to run as"
116
- task :create_memcached_user_and_group, :roles => :cache do
117
- deprec2.groupadd(memcached_group)
118
- deprec2.useradd(memcached_user, :group => memcached_group, :homedir => false)
119
- # Set the primary group for the memcached user (in case user already existed
120
- # when previous command was run)
121
- sudo "usermod --gid #{memcached_group} #{memcached_user}"
122
- end
123
-
124
- desc "set group ownership and permissions on dirs memcached needs to write to"
125
- task :set_perms_for_memcached_dirs, :roles => :cache do
126
- # sudo "chgrp -R #{memcached_group} #{memcached_run_dir}"
127
- # sudo "chmod -R g+w #{memcached_run_dir}"
128
- end
129
-
130
- task :symlink_init_d, :roles => :cache do
131
- sudo "ln -fs #{deploy_to}/memcached/memcached/etc/init.d/memcached /etc/init.d/memcached_#{memcached_port}"
132
- end
133
-
134
- task :symlink_monit_d, :roles => :cache do
135
- sudo "ln -fs #{deploy_to}/memcached/memcached/etc/monit.d/monit_memcached.conf /etc/monit.d/monit_memcached_#{memcached_port}.conf"
136
- end
137
-
138
- end
139
- end
140
- end
@@ -1,135 +0,0 @@
1
- # Copyright 2006-2008 by Mike Bailey. All rights reserved.
2
- Capistrano::Configuration.instance(:must_exist).load do
3
- namespace :chrisrec do
4
- namespace :munin do
5
-
6
- set :use_nginx, false
7
- set :use_apache, true
8
- set :munin_user, 'munin'
9
- set :munin_group, 'munin'
10
- set :munin_webserver_auth_user, 'admin'
11
- set :munin_webserver_auth_pass, 'XXXX'
12
-
13
- set :local_template_dir, "#{File.dirname(__FILE__)}/../../template"
14
-
15
- desc "Install munin"
16
- task :install, :roles => :web do
17
- install_deps
18
- create_munin_user
19
- deprec2.mkdir("#{deploy_to}/munin/html", :group => munin_group, :mode => 0775, :via => :sudo)
20
- end
21
-
22
- task :install_deps do
23
- apt.install( {:base => %w(munin munin-node)}, :stable )
24
- end
25
-
26
- task :create_munin_user do
27
- deprec2.groupadd(munin_group)
28
- deprec2.useradd(munin_user, :group => munin_group, :homedir => false)
29
- end
30
-
31
- SYSTEM_CONFIG_FILES[:munin] = [
32
-
33
- {:template => 'munin.conf.erb',
34
- :path => '/etc/munin/munin.conf',
35
- :mode => 0664,
36
- :owner => 'root:root'}
37
- ]
38
-
39
- PROJECT_CONFIG_FILES[:munin_nginx] = [
40
-
41
- {:template => 'munin_nginx_vhost.conf.erb',
42
- :path => "conf/munin_nginx_vhost.conf",
43
- :mode => 0644,
44
- :owner => 'root:root'}
45
- ]
46
-
47
- PROJECT_CONFIG_FILES[:munin_apache] = [
48
-
49
- {:template => "httpd-vhost-munin.conf.erb",
50
- :path => 'conf/httpd-vhost-munin.conf',
51
- :mode => 0755,
52
- :owner => 'root:root'}
53
- ]
54
-
55
- desc "Generate configuration file(s) for munin from template(s)"
56
- task :config_gen do
57
- SYSTEM_CONFIG_FILES[:munin].each do |file|
58
- deprec2.render_template(:munin, file)
59
- end
60
-
61
- PROJECT_CONFIG_FILES[:munin_nginx].each do |file|
62
- deprec2.render_template(:munin, file)
63
- end if use_nginx
64
-
65
- PROJECT_CONFIG_FILES[:munin_apache].each do |file|
66
- deprec2.render_template(:munin, file)
67
- end if use_apache
68
- end
69
-
70
- desc 'Deploy configuration files(s) for munin'
71
- task :config, :roles => :web do
72
- deprec2.push_configs(:munin, SYSTEM_CONFIG_FILES[:munin])
73
- deprec2.push_configs(:munin, PROJECT_CONFIG_FILES[:munin_nginx]) if use_nginx
74
- deprec2.push_configs(:munin, PROJECT_CONFIG_FILES[:munin_apache]) if use_apache
75
- symlink_nginx_vhost if use_nginx
76
- symlink_apache_vhost if use_apache
77
- auth_user if use_apache
78
- end
79
-
80
- task :symlink_nginx_vhost, :roles => :web do
81
- return unless use_nginx
82
- sudo "ln -sf #{deploy_to}/munin/conf/munin_nginx_vhost.conf #{nginx_vhost_dir}/munin.conf"
83
- end
84
-
85
- task :symlink_apache_vhost, :roles => :web do
86
- return unless use_apache
87
- sudo "ln -sf #{deploy_to}/munin/conf/httpd-vhost-munin.conf /etc/apache2/sites-available/munin"
88
- sudo "ln -sf #{deploy_to}/munin/conf/httpd-vhost-munin.conf /etc/apache2/sites-enabled/munin"
89
- end
90
-
91
- task :auth_user, :roles => :web do
92
- set (:munin_webserver_auth_user) {
93
- Capistrano::CLI.ui.ask "Enter munin web user" do |q|
94
- q.default = 'admin'
95
- end
96
- }
97
-
98
- set (:munin_webserver_auth_pass) {
99
- Capistrano::CLI.ui.ask "Enter munin web user password"
100
- }
101
-
102
-
103
- sudo "/usr/bin/htpasswd -c -b #{deploy_to}/munin/htpasswd.users #{munin_webserver_auth_user} #{munin_webserver_auth_pass}"
104
- end
105
-
106
- desc "start munin"
107
- task :start, :roles => :web do
108
- send(run_method, "/etc/init.d/munin-node start")
109
- end
110
-
111
- desc "stop munin"
112
- task :stop, :roles => :web do
113
- send(run_method, "/etc/init.d/munin-node stop")
114
- end
115
-
116
- desc "restart munin"
117
- task :restart, :roles => :web do
118
- send(run_method, "/etc/init.d/munin-node restart")
119
- end
120
-
121
- task :activate, :roles => :web do
122
- end
123
-
124
- task :deactivate, :roles => :web do
125
- end
126
-
127
- task :backup, :roles => :web do
128
- end
129
-
130
- task :restore, :roles => :web do
131
- end
132
-
133
- end
134
- end
135
- end
@@ -1,95 +0,0 @@
1
- # COPY TO YOUR lib/rake directory
2
- require 'fileutils'
3
- require 'active_record'
4
- require 'erb'
5
-
6
- namespace :mysql do
7
- DUMP_FILENAME = [RAILS_ENV, Time.now.utc.strftime('%Y-%m-%d_%H-%M-%S')].join('_') + '.sql.bz2'
8
- DUMP_LOCATION = File.join(RAILS_ROOT, 'db', 'dumps')
9
-
10
- def populate_config
11
- ActiveRecord::Base.configurations = Rails::Configuration.new.database_configuration
12
- end
13
-
14
- def conf
15
- populate_config if ActiveRecord::Base.configurations.empty?
16
- @conf ||= ActiveRecord::Base.configurations[RAILS_ENV]
17
- end
18
-
19
- def mysql_opts
20
- user = conf['user'] || conf['username']
21
- opts = []
22
- opts << "--user=#{user}" if user
23
- opts << "--password=#{conf['password']}" if conf['password']
24
- opts << "--host=#{conf['host']}" if conf['host']
25
- opts << "--port=#{conf['port']}" if conf['port']
26
- opts << "--default-character-set=#{conf['encoding']}" if conf['encoding']
27
- opts << "#{conf['database']}"
28
- opts.join(' ')
29
- end
30
-
31
- def dump_cmd
32
- "mysqldump --skip-lock-tables #{mysql_opts} | bzip2"
33
- end
34
-
35
- def load_cmd
36
- "bunzip2 | mysql #{mysql_opts}"
37
- end
38
-
39
- def overwrite_db_with(file_or_io)
40
- IO.popen(load_cmd, 'w') { |mysql| mysql << file_or_io.read }
41
- end
42
-
43
- task :ensure_mysql do
44
- abort "Sorry, you have to be using MySQL locally" unless conf['adapter'] == 'mysql'
45
- ActiveRecord::Base.establish_connection
46
- end
47
-
48
- desc <<-DESC
49
- Prints out information about the charsets and collations used by the MySQL
50
- connection of the current environment
51
- DESC
52
- task :charset_info => :ensure_mysql do
53
- charset_vars = ActiveRecord::Base.connection.execute("show variables like 'character\_set\_%'")
54
- collation_vars = ActiveRecord::Base.connection.execute("show variables like 'colla%'")
55
- puts "ActiveRecord::Base.connection.charset: #{ActiveRecord::Base.connection.charset}"
56
- puts "ActiveRecord::Base.connection.collation: #{ActiveRecord::Base.connection.collation}"
57
- [charset_vars, collation_vars].each do |resultset|
58
- resultset.each do |variable, value|
59
- puts "#{variable}: #{value}"
60
- end
61
- end
62
- end
63
-
64
- desc 'Dumps the a mysql db of the current environment to standard out'
65
- task :stream_dump => :ensure_mysql do
66
- exec dump_cmd
67
- end
68
-
69
- desc <<-DESC
70
- Pipes STDIN into the local MySQL DB.\
71
- Warning! May replace current DB entirely, use with care.\
72
- Reverse of mysql:stream_dump
73
- DESC
74
- task :load_dump => :dump do
75
- overwrite_db_with $stdin
76
- puts "loaded other database into #{conf['database']}"
77
- end
78
-
79
- desc 'Dump the database for the current environment into /db/dumps'
80
- task :dump => :ensure_mysql do
81
- FileUtils.mkdir_p DUMP_LOCATION
82
- dumpfile = File.join(DUMP_LOCATION, DUMP_FILENAME)
83
- puts "created #{dumpfile.gsub(RAILS_ROOT,'')}" if system "#{dump_cmd} > #{dumpfile}"
84
- end
85
-
86
- desc 'Loads the last dump into the DB'
87
- task :restore => :ensure_mysql do
88
- Dir.chdir DUMP_LOCATION do
89
- last_filename = Dir.glob("#{RAILS_ENV}_*.sql.bz2").sort.last
90
- abort 'Sorry, no restorable dump found' unless last_filename
91
- File.open(last_filename, 'r') { |dumpfile| overwrite_db_with dumpfile }
92
- puts "Restored backup #{last_filename}"
93
- end
94
- end
95
- end
@@ -1,51 +0,0 @@
1
- require 'fileutils'
2
-
3
- Capistrano::Configuration.instance(:must_exist).load do
4
- namespace :chrisrec do
5
-
6
- set :db_dump_filename do
7
- [rails_env, release_name].join('_') + '.sql.bz2'
8
- end
9
-
10
- namespace :mysql do
11
-
12
- desc 'Dump the remote database'
13
- task :dump, :roles => :db, :only => { :primary => true } do
14
- top.chrisrec.remote_rake 'mysql:dump'
15
- end
16
-
17
- desc 'Restore the latest database dump'
18
- task :restore, :roles => :db, :only => { :primary => true } do
19
- top.chrisrec.remote_rake 'mysql:restore'
20
- end
21
-
22
- desc 'Dumps the remote database and copies the dump to the shared directory'
23
- task :backup_dump, :roles => :db, :only => { :primary => true } do
24
- destination = fetch(:db_backup_location, File.join(deploy_to, shared_dir, 'db_dumps'))
25
- run "mkdir -p #{destination}"
26
- top.chrisrec.remote_rake "mysql:stream_dump > #{File.join(destination, db_dump_filename)}"
27
- end
28
-
29
- desc 'Creates a dump of the remote database and copies it to the local working dir'
30
- task :fetch_dump, :roles => :db, :only => { :primary => true } do
31
- host = roles[:db].servers.first.host
32
- destination = fetch(:db_dump_location, File.join('db', 'dumps', host))
33
- tempfile = File.join('tmp', db_dump_filename)
34
- FileUtils.mkdir_p destination unless File.directory?(destination) || File.symlink?(destination)
35
- top.chrisrec.remote_rake "mysql:stream_dump > #{tempfile}"
36
- get File.join(deploy_to, 'current', tempfile), File.join(destination, db_dump_filename)
37
- run "rm -f #{tempfile}" # delete tempfile # doesnt work!?!
38
- end
39
-
40
- desc 'Clones the remote db, replacing the local development one'
41
- task :duplicate, :roles => :db, :only => { :primary => true } do
42
- IO.popen('rake mysql:load_dump', 'w') do |local_mysql|
43
- top.chrisrec.remote_rake('mysql:stream_dump', :pty => false) do |channel, stream, data|
44
- next if stream == :err
45
- local_mysql << data
46
- end
47
- end
48
- end
49
- end
50
- end
51
- end
@@ -1,19 +0,0 @@
1
- Capistrano::Configuration.instance(:must_exist).load do
2
- namespace :chrisrec do
3
- def remote_rake(task, options={}, &block)
4
- rake = fetch(:rake, 'rake')
5
- run("cd #{deploy_to}/current && RAILS_ENV=#{rails_env} #{rake} #{task}", options, &block)
6
- end
7
-
8
- desc %Q{\
9
- Invokes rake task in currently deployed app\
10
- specify task(s) to be in ENV variable TASK\
11
- Example: cap rake TASK=db:migrate
12
- }
13
- task :rake do
14
- task = ENV['TASK'] || ENV['TASKS']
15
- abort 'please specify a TASK env variable' unless task
16
- remote_rake task
17
- end
18
- end
19
- end
@@ -1,35 +0,0 @@
1
- Capistrano::Configuration.instance(:must_exist).load do
2
- namespace :chrisrec do
3
- namespace :rakecron do
4
-
5
- # role :cron, "TODO"
6
- set :rakecron_log_dir, "/var/log"
7
- set :local_template_dir, "#{File.dirname(__FILE__)}/../../template"
8
-
9
- PROJECT_CONFIG_FILES[:rakecron] = [
10
- {:template => 'rakecron.erb',
11
- :path => 'crontab',
12
- :mode => 0664,
13
- :owner => 'root:root'}
14
- ]
15
-
16
- desc "Generate configuration file(s) for from template(s)"
17
- task :config_gen do
18
- PROJECT_CONFIG_FILES[:rakecron].each do |file|
19
- deprec2.render_template(:rakecron, file)
20
- end
21
- end
22
-
23
- desc 'Deploy configuration files(s) for rakecron'
24
- task :config, :roles => :cron do
25
- deprec2.push_configs(:rakecron, PROJECT_CONFIG_FILES[:rakecron])
26
- symlink_cron_job
27
- end
28
-
29
- task :symlink_cron_job, :roles => :cron do
30
- sudo "ln -sf #{deploy_to}/rakecron/crontab /etc/cron.d/rakecron_#{application}"
31
- end
32
-
33
- end
34
- end
35
- end