chrisrec 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest +44 -0
- data/Rakefile +2 -2
- data/chrisrec.gemspec +3 -3
- data/pkg/chrisrec-0.1.2/Manifest +88 -0
- data/pkg/chrisrec-0.1.2/README +1 -0
- data/pkg/chrisrec-0.1.2/Rakefile +21 -0
- data/pkg/chrisrec-0.1.2/chrisrec.gemspec +30 -0
- data/pkg/chrisrec-0.1.2/lib/backgroundrb/backgroundrb.rb +22 -0
- data/pkg/chrisrec-0.1.2/lib/chrisrec.rb +14 -0
- data/pkg/chrisrec-0.1.2/lib/console/console.rb +19 -0
- data/pkg/chrisrec-0.1.2/lib/daemon/daemon.rb +134 -0
- data/pkg/chrisrec-0.1.2/lib/gitosis/gitosis.rb +131 -0
- data/pkg/chrisrec-0.1.2/lib/jekyll/jekyll.rb +87 -0
- data/pkg/chrisrec-0.1.2/lib/memcached/memcached.rb +140 -0
- data/pkg/chrisrec-0.1.2/lib/munin/munin.rb +135 -0
- data/pkg/chrisrec-0.1.2/lib/mysql/mysql.rake +95 -0
- data/pkg/chrisrec-0.1.2/lib/mysql/mysql.rb +51 -0
- data/pkg/chrisrec-0.1.2/lib/rake/rake.rb +19 -0
- data/pkg/chrisrec-0.1.2/lib/rakecron/rakecron.rb +35 -0
- data/pkg/chrisrec-0.1.2/lib/starling/starling.rb +124 -0
- data/pkg/chrisrec-0.1.2/lib/static/static.rb +80 -0
- data/pkg/chrisrec-0.1.2/lib/tomcat/tomcat.rb +202 -0
- data/pkg/chrisrec-0.1.2/lib/workling/workling.rb +72 -0
- data/pkg/chrisrec-0.1.2/template/daemon/daemon-init-script.erb +59 -0
- data/pkg/chrisrec-0.1.2/template/daemon/monit.conf.erb +4 -0
- data/pkg/chrisrec-0.1.2/template/jekyll/httpd-vhost-jekyll.conf.erb +16 -0
- data/pkg/chrisrec-0.1.2/template/memcached/memcached-conf.erb +1 -0
- data/pkg/chrisrec-0.1.2/template/memcached/memcached.erb +59 -0
- data/pkg/chrisrec-0.1.2/template/memcached/monit.conf.erb +8 -0
- data/pkg/chrisrec-0.1.2/template/memcached/start-memcached.erb +118 -0
- data/pkg/chrisrec-0.1.2/template/munin/httpd-vhost-munin.conf.erb +20 -0
- data/pkg/chrisrec-0.1.2/template/munin/munin.conf.erb +70 -0
- data/pkg/chrisrec-0.1.2/template/munin/munin_nginx_vhost.conf.erb +24 -0
- data/pkg/chrisrec-0.1.2/template/rakecron/rakecron.erb +12 -0
- data/pkg/chrisrec-0.1.2/template/starling/monit.conf.erb +14 -0
- data/pkg/chrisrec-0.1.2/template/starling/starling-init-script.erb +69 -0
- data/pkg/chrisrec-0.1.2/template/static/httpd-vhost-static.conf.erb +16 -0
- data/pkg/chrisrec-0.1.2/template/tomcat/conf/server.xml.erb +33 -0
- data/pkg/chrisrec-0.1.2/template/tomcat/conf/web.xml +1194 -0
- data/pkg/chrisrec-0.1.2/template/tomcat/logs/empty.txt +1 -0
- data/pkg/chrisrec-0.1.2/template/tomcat/monit.conf.erb +8 -0
- data/pkg/chrisrec-0.1.2/template/tomcat/temp/empty.txt +1 -0
- data/pkg/chrisrec-0.1.2/template/tomcat/tomcat.erb +28 -0
- data/pkg/chrisrec-0.1.2/template/tomcat/webapps/empty.txt +1 -0
- data/pkg/chrisrec-0.1.2/template/tomcat/work/empty.txt +1 -0
- data/pkg/chrisrec-0.1.2/template/workling/monit.conf.erb +4 -0
- data/pkg/chrisrec-0.1.2/template/workling/workling-init-script.erb +56 -0
- metadata +48 -4
@@ -0,0 +1,202 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
namespace :chrisrec do
|
3
|
+
namespace :tomcat do
|
4
|
+
|
5
|
+
set :maven_env, "production"
|
6
|
+
set :tomcat_war, "MyAppName"
|
7
|
+
|
8
|
+
set :tomcat_address, '127.0.0.1'
|
9
|
+
set :tomcat_port, 8080
|
10
|
+
set :tomcat_shutdown_port, 8009
|
11
|
+
set :tomcat_ssl_port, 8443
|
12
|
+
|
13
|
+
set :local_template_dir, "#{File.dirname(__FILE__)}/../../template"
|
14
|
+
|
15
|
+
desc "Install tomcat"
|
16
|
+
task :install, :roles => :app do
|
17
|
+
version = 'apache-tomcat-6.0.20'
|
18
|
+
set :src_package, {
|
19
|
+
:file => version + '.tar.gz',
|
20
|
+
# :md5sum => 'a08851f7fa7b15e92ee6320b7a79c321 tomcat-1.2.2.tar.gz',
|
21
|
+
:dir => version,
|
22
|
+
:url => "http://apache.16degrees.com.au/tomcat/tomcat-6/v6.0.20/bin/apache-tomcat-6.0.20.tar.gz",
|
23
|
+
:unpack => "tar zxf #{version}.tar.gz;"
|
24
|
+
}
|
25
|
+
|
26
|
+
deprec2.download_src(src_package, src_dir)
|
27
|
+
deprec2.unpack_src(src_package, src_dir)
|
28
|
+
|
29
|
+
sudo "sudo mv #{src_dir}/#{version} /usr/local/tomcat"
|
30
|
+
|
31
|
+
install_java
|
32
|
+
end
|
33
|
+
|
34
|
+
task :install_java do
|
35
|
+
# puts "sudo vi /etc/apt/sources.list"
|
36
|
+
sudo "chmod 666 /etc/apt/sources.list"
|
37
|
+
sudo "grep 'multiverse$' /etc/apt/sources.list || sudo echo \"\"\n\"deb http://archive.ubuntu.com/ubuntu/ intrepid multiverse\" >> /etc/apt/sources.list"
|
38
|
+
sudo "chmod 644 /etc/apt/sources.list"
|
39
|
+
|
40
|
+
apt.update
|
41
|
+
apt.install( {:base => %w(maven2)}, :stable )
|
42
|
+
|
43
|
+
top.chrisrec.tomcat.deploy.setup
|
44
|
+
|
45
|
+
puts "*******************"
|
46
|
+
puts "*******************"
|
47
|
+
puts "******************* cannot automate the sun java install"
|
48
|
+
puts "******************* run : sudo apt-get install sun-java6-bin sun-java6-jre sun-java6-jdk"
|
49
|
+
puts "*******************"
|
50
|
+
puts "*******************"
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
# Configure
|
55
|
+
SYSTEM_CONFIG_FILES[:tomcat] = [
|
56
|
+
{:template => 'tomcat.erb',
|
57
|
+
:path => 'tomcat/etc/init.d/tomcat',
|
58
|
+
:mode => 0755,
|
59
|
+
:owner => 'root:root'},
|
60
|
+
|
61
|
+
{:template => 'monit.conf.erb',
|
62
|
+
:path => "tomcat/etc/monit.d/monit_tomcat.conf",
|
63
|
+
:mode => 0600,
|
64
|
+
:owner => 'root:root'},
|
65
|
+
|
66
|
+
{:template => 'conf/server.xml.erb',
|
67
|
+
:path => "conf/server.xml",
|
68
|
+
:mode => 0644,
|
69
|
+
:owner => 'root:root'},
|
70
|
+
|
71
|
+
{:template => 'conf/web.xml',
|
72
|
+
:path => "conf/web.xml",
|
73
|
+
:mode => 0644,
|
74
|
+
:owner => 'root:root'},
|
75
|
+
|
76
|
+
{:template => 'temp/empty.txt',
|
77
|
+
:path => "temp/empty.txt",
|
78
|
+
:mode => 0644,
|
79
|
+
:owner => 'root:root'},
|
80
|
+
|
81
|
+
{:template => 'logs/empty.txt',
|
82
|
+
:path => "logs/empty.txt",
|
83
|
+
:mode => 0644,
|
84
|
+
:owner => 'root:root'},
|
85
|
+
|
86
|
+
{:template => 'webapps/empty.txt',
|
87
|
+
:path => "webapps/empty.txt",
|
88
|
+
:mode => 0644,
|
89
|
+
:owner => 'root:root'},
|
90
|
+
|
91
|
+
{:template => 'work/empty.txt',
|
92
|
+
:path => "work/empty.txt",
|
93
|
+
:mode => 0644,
|
94
|
+
:owner => 'root:root'}
|
95
|
+
]
|
96
|
+
|
97
|
+
# Generating Configuration Files
|
98
|
+
desc "Generate configuration file(s) for tomcat from template(s)"
|
99
|
+
task :config_gen do
|
100
|
+
SYSTEM_CONFIG_FILES[:tomcat].each do |file|
|
101
|
+
deprec2.render_template(:tomcat, file)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
desc 'Deploy configuration files(s) for tomcat'
|
106
|
+
task :config, :roles => :app do
|
107
|
+
|
108
|
+
deprec2.push_configs(:tomcat, SYSTEM_CONFIG_FILES[:tomcat])
|
109
|
+
symlink_init_d
|
110
|
+
symlink_monit_d
|
111
|
+
|
112
|
+
activate
|
113
|
+
end
|
114
|
+
|
115
|
+
desc "Stop tomcat"
|
116
|
+
task :stop , :roles => :app do
|
117
|
+
sudo "/etc/init.d/tomcat_#{tomcat_port} stop"
|
118
|
+
end
|
119
|
+
|
120
|
+
desc "Start tomcat"
|
121
|
+
task :start , :roles => :app do
|
122
|
+
sudo "/etc/init.d/tomcat_#{tomcat_port} start"
|
123
|
+
end
|
124
|
+
|
125
|
+
desc "Start the tomcat server"
|
126
|
+
task :restart, :roles => :app do
|
127
|
+
stop
|
128
|
+
sleep(2)
|
129
|
+
start
|
130
|
+
end
|
131
|
+
|
132
|
+
task :activate, :roles => :app do
|
133
|
+
send(run_method, "update-rc.d tomcat_#{tomcat_port} defaults")
|
134
|
+
end
|
135
|
+
|
136
|
+
task :deactivate, :roles => :app do
|
137
|
+
send(run_method, "update-rc.d -f tomcat_#{tomcat_port} remove")
|
138
|
+
end
|
139
|
+
|
140
|
+
task :symlink_init_d, :roles => :app do
|
141
|
+
sudo "ln -fs #{deploy_to}/tomcat/tomcat/etc/init.d/tomcat /etc/init.d/tomcat_#{tomcat_port}"
|
142
|
+
end
|
143
|
+
|
144
|
+
task :symlink_monit_d, :roles => :app do
|
145
|
+
sudo "ln -fs #{deploy_to}/tomcat/tomcat/etc/monit.d/monit_tomcat.conf /etc/monit.d/monit_tomcat_#{tomcat_port}.conf"
|
146
|
+
end
|
147
|
+
|
148
|
+
namespace :deploy do
|
149
|
+
desc 'deploy'
|
150
|
+
task :default do
|
151
|
+
strategy.deploy!
|
152
|
+
|
153
|
+
top.chrisrec.tomcat.stop
|
154
|
+
|
155
|
+
run "rm -f #{current_path} && ln -s #{latest_release} #{current_path}"
|
156
|
+
if dependent_projects
|
157
|
+
dependent_projects.each do | project |
|
158
|
+
name = project.scan(/:(.*)/).flatten.to_s
|
159
|
+
run "git clone #{project} #{current_path}/#{name}"
|
160
|
+
run "cd #{current_path}/#{name} && mvn clean -P #{maven_env}"
|
161
|
+
run "cd #{current_path}/#{name} && mvn compile -P #{maven_env}"
|
162
|
+
run "cd #{current_path}/#{name} && mvn install -P #{maven_env}"
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
run "cd #{current_path} && mvn clean -P #{maven_env}"
|
167
|
+
run "cd #{current_path} && mvn compile -P #{maven_env}"
|
168
|
+
run "cd #{current_path} && mvn package -P #{maven_env}"
|
169
|
+
|
170
|
+
sudo "rm -f #{deploy_to}/tomcat/webapps/#{tomcat_war}.war"
|
171
|
+
sudo "rm -rf #{deploy_to}/tomcat/webapps/#{tomcat_war}"
|
172
|
+
|
173
|
+
sudo "cp #{current_path}/target/#{tomcat_war}.war #{deploy_to}/tomcat/webapps"
|
174
|
+
|
175
|
+
top.chrisrec.tomcat.start
|
176
|
+
end
|
177
|
+
|
178
|
+
desc 'setup'
|
179
|
+
task :setup do
|
180
|
+
dirs = [deploy_to, releases_path]
|
181
|
+
sudo "mkdir -p #{dirs.join(' ')}"
|
182
|
+
sudo "chgrp -R #{group} #{dirs.join(' ')}"
|
183
|
+
sudo "chmod g+w #{dirs.join(' ')}"
|
184
|
+
end
|
185
|
+
|
186
|
+
desc 'rollback'
|
187
|
+
task :rollback do
|
188
|
+
if previous_release
|
189
|
+
run "rm #{current_path}; ln -s #{previous_release} #{current_path}"
|
190
|
+
else
|
191
|
+
abort "could not rollback the code because there is no prior release"
|
192
|
+
end
|
193
|
+
|
194
|
+
run "if [ `readlink #{current_path}` != #{current_release} ]; then rm -rf #{current_release}; fi"
|
195
|
+
|
196
|
+
top.chrisrec.tomcat.restart
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
namespace :chrisrec do
|
3
|
+
namespace :workling do
|
4
|
+
|
5
|
+
set :local_template_dir, "#{File.dirname(__FILE__)}/../../template"
|
6
|
+
|
7
|
+
SYSTEM_CONFIG_FILES[:workling] = [
|
8
|
+
{:template => 'workling-init-script.erb',
|
9
|
+
:path => 'workling/etc/init.d/workling',
|
10
|
+
:mode => 0755,
|
11
|
+
:owner => 'root:root'},
|
12
|
+
|
13
|
+
{:template => 'monit.conf.erb',
|
14
|
+
:path => "workling/etc/monit.d/monit_workling.conf",
|
15
|
+
:mode => 0600,
|
16
|
+
:owner => 'root:root'}
|
17
|
+
]
|
18
|
+
|
19
|
+
# Generating Configuration Files
|
20
|
+
desc "Generate configuration file(s) for workling from template(s)"
|
21
|
+
task :config_gen do
|
22
|
+
SYSTEM_CONFIG_FILES[:workling].each do |file|
|
23
|
+
deprec2.render_template(:workling, file)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
desc 'Deploy configuration files(s) for workling'
|
28
|
+
task :config, :roles => :app do
|
29
|
+
deprec2.push_configs(:workling, SYSTEM_CONFIG_FILES[:workling])
|
30
|
+
symlink_init_d
|
31
|
+
symlink_monit_d
|
32
|
+
|
33
|
+
activate
|
34
|
+
end
|
35
|
+
|
36
|
+
desc "Stop workling"
|
37
|
+
task :stop , :roles => :app do
|
38
|
+
sudo "/etc/init.d/workling_#{starling_port} stop"
|
39
|
+
end
|
40
|
+
|
41
|
+
desc "Start workling"
|
42
|
+
task :start , :roles => :app do
|
43
|
+
sudo "/etc/init.d/workling_#{starling_port} start"
|
44
|
+
end
|
45
|
+
|
46
|
+
desc "Start the workling server"
|
47
|
+
task :restart, :roles => :app do
|
48
|
+
stop
|
49
|
+
sleep(2)
|
50
|
+
start
|
51
|
+
end
|
52
|
+
|
53
|
+
task :activate, :roles => :app do
|
54
|
+
send(run_method, "update-rc.d workling_#{starling_port} defaults")
|
55
|
+
end
|
56
|
+
|
57
|
+
task :deactivate, :roles => :app do
|
58
|
+
send(run_method, "update-rc.d -f workling_#{starling_port} remove")
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
task :symlink_init_d do
|
63
|
+
sudo "ln -fs #{deploy_to}/workling/workling/etc/init.d/workling /etc/init.d/workling_#{starling_port}"
|
64
|
+
end
|
65
|
+
|
66
|
+
task :symlink_monit_d do
|
67
|
+
sudo "ln -fs #{deploy_to}/workling/workling/etc/monit.d/monit_workling.conf /etc/monit.d/monit_workling_#{starling_port}.conf"
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
#! /bin/sh
|
2
|
+
#
|
3
|
+
### BEGIN INIT INFO
|
4
|
+
# Provides: defaultdaemon
|
5
|
+
# Required-Start: $remote_fs $syslog
|
6
|
+
# Required-Stop: $remote_fs $syslog
|
7
|
+
# Default-Start: 2 3 4 5
|
8
|
+
# Default-Stop: 0 1 6
|
9
|
+
# Short-Description: Start daemon at boot time
|
10
|
+
# Description: Enable service provided by daemon.
|
11
|
+
### END INIT INFO
|
12
|
+
|
13
|
+
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
14
|
+
DAEMON=<%=deploy_to%>/current/<%=daemon%>
|
15
|
+
NAME=<%=daemon_name%>
|
16
|
+
DESC=<%=daemon_name%>
|
17
|
+
PIDFILE=<%=deploy_to%>/current/tmp/pids/<%=daemon_pid%>
|
18
|
+
|
19
|
+
test -x $DAEMON || exit 0
|
20
|
+
|
21
|
+
set -e
|
22
|
+
|
23
|
+
case "$1" in
|
24
|
+
start)
|
25
|
+
echo -n "Starting $DESC: "
|
26
|
+
cd <%=deploy_to%>/current && PATH=/opt/ruby-enterprise/bin:$PATH DAEMON_ENV=<%=daemon_env%> $DAEMON start
|
27
|
+
echo "$NAME."
|
28
|
+
;;
|
29
|
+
stop)
|
30
|
+
echo -n "Stopping $DESC: "
|
31
|
+
# cd <%=deploy_to%>/current && PATH=/opt/ruby-enterprise/bin:$PATH DAEMON_ENV=<%=daemon_env%> $DAEMON stop
|
32
|
+
echo "$NAME."
|
33
|
+
[ -f $PIDFILE ] && kill -9 `tail $PIDFILE`
|
34
|
+
rm -f $PIDFILE
|
35
|
+
;;
|
36
|
+
|
37
|
+
restart|force-reload)
|
38
|
+
#
|
39
|
+
# If the "reload" option is implemented, move the "force-reload"
|
40
|
+
# option to the "reload" entry above. If not, "force-reload" is
|
41
|
+
# just the same as "restart".
|
42
|
+
#
|
43
|
+
echo -n "Restarting $DESC: "
|
44
|
+
# cd <%=deploy_to%>/current && PATH=/opt/ruby-enterprise/bin:$PATH RAILS_ENV=<%=rails_env%> $DAEMON stop
|
45
|
+
sleep 1
|
46
|
+
[ -f $PIDFILE ] && kill -9 `tail $PIDFILE`
|
47
|
+
rm -f $PIDFILE
|
48
|
+
cd <%=deploy_to%>/current && PATH=/opt/ruby-enterprise/bin:$PATH RAILS_ENV=<%=daemon_env%> $DAEMON start
|
49
|
+
echo "$NAME."
|
50
|
+
;;
|
51
|
+
*)
|
52
|
+
N=/etc/init.d/$NAME
|
53
|
+
# echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
|
54
|
+
echo "Usage: $N {start|stop|restart|force-reload}" >&2
|
55
|
+
exit 1
|
56
|
+
;;
|
57
|
+
esac
|
58
|
+
|
59
|
+
exit 0
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Listen 9080
|
2
|
+
<VirtualHost *:9080>
|
3
|
+
ServerName <%= domain %>
|
4
|
+
|
5
|
+
DocumentRoot <%= "#{deploy_to}/current" %>
|
6
|
+
|
7
|
+
<Directory <%= "#{deploy_to}/current" %>>
|
8
|
+
Options Indexes FollowSymLinks MultiViews
|
9
|
+
AllowOverride None
|
10
|
+
Order allow,deny
|
11
|
+
allow from all
|
12
|
+
</Directory>
|
13
|
+
|
14
|
+
ErrorLog /var/log/jekyll_log
|
15
|
+
CustomLog /var/log/jekyll-access_log combined
|
16
|
+
</VirtualHost>
|
@@ -0,0 +1 @@
|
|
1
|
+
-u <%= memcached_user %> -m <%=memcache_memory%> -l <%= memcached_address %> -p <%= memcached_port %>
|
@@ -0,0 +1,59 @@
|
|
1
|
+
#! /bin/sh
|
2
|
+
#
|
3
|
+
### BEGIN INIT INFO
|
4
|
+
# Provides: defaultdaemon
|
5
|
+
# Required-Start: $remote_fs $syslog
|
6
|
+
# Required-Stop: $remote_fs $syslog
|
7
|
+
# Default-Start: 2 3 4 5
|
8
|
+
# Default-Stop: 0 1 6
|
9
|
+
# Short-Description: Start daemon at boot time
|
10
|
+
# Description: Enable service provided by daemon.
|
11
|
+
### END INIT INFO
|
12
|
+
|
13
|
+
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
14
|
+
DAEMON=/usr/local/bin/memcached
|
15
|
+
DAEMONBOOTSTRAP=<%=deploy_to%>/memcached/memcached/etc/init.d/start-memcached
|
16
|
+
NAME=memcached
|
17
|
+
DESC=memcached
|
18
|
+
PIDFILE=<%=memcached_run_dir%>/memcached_<%=memcached_port%>.pid
|
19
|
+
|
20
|
+
test -x $DAEMON || exit 0
|
21
|
+
test -x $DAEMONBOOTSTRAP || exit 0
|
22
|
+
|
23
|
+
set -e
|
24
|
+
|
25
|
+
case "$1" in
|
26
|
+
start)
|
27
|
+
echo -n "Starting $DESC: "
|
28
|
+
start-stop-daemon --start --quiet --exec $DAEMONBOOTSTRAP
|
29
|
+
echo "$NAME."
|
30
|
+
;;
|
31
|
+
stop)
|
32
|
+
echo -n "Stopping $DESC: "
|
33
|
+
start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON
|
34
|
+
echo "$NAME."
|
35
|
+
rm -f $PIDFILE
|
36
|
+
;;
|
37
|
+
|
38
|
+
restart|force-reload)
|
39
|
+
#
|
40
|
+
# If the "reload" option is implemented, move the "force-reload"
|
41
|
+
# option to the "reload" entry above. If not, "force-reload" is
|
42
|
+
# just the same as "restart".
|
43
|
+
#
|
44
|
+
echo -n "Restarting $DESC: "
|
45
|
+
start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE
|
46
|
+
rm -f $PIDFILE
|
47
|
+
sleep 1
|
48
|
+
start-stop-daemon --start --quiet --exec $DAEMONBOOTSTRAP
|
49
|
+
echo "$NAME."
|
50
|
+
;;
|
51
|
+
*)
|
52
|
+
N=/etc/init.d/$NAME
|
53
|
+
# echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
|
54
|
+
echo "Usage: $N {start|stop|restart|force-reload}" >&2
|
55
|
+
exit 1
|
56
|
+
;;
|
57
|
+
esac
|
58
|
+
|
59
|
+
exit 0
|
@@ -0,0 +1,8 @@
|
|
1
|
+
check process memcached_<%= memcached_port %> with pidfile <%= memcached_run_dir %>/memcached_<%= memcached_port %>.pid
|
2
|
+
group memcached_<%= memcached_port %>
|
3
|
+
start program = "/etc/init.d/memcached_<%= memcached_port %> start"
|
4
|
+
stop program = "/etc/init.d/memcached_<%= memcached_port %> stop"
|
5
|
+
|
6
|
+
if failed host <%= memcached_address %> port <%= memcached_port %>
|
7
|
+
with timeout 10 seconds
|
8
|
+
then alert
|
@@ -0,0 +1,118 @@
|
|
1
|
+
#!/usr/bin/perl -w
|
2
|
+
|
3
|
+
# start-memcached
|
4
|
+
# 2003/2004 - Jay Bonci <jaybonci@debian.org>
|
5
|
+
# This script handles the parsing of the /etc/memcached.conf file
|
6
|
+
# and was originally created for the Debian distribution.
|
7
|
+
# Anyone may use this little script under the same terms as
|
8
|
+
# memcached itself.
|
9
|
+
|
10
|
+
use strict;
|
11
|
+
|
12
|
+
if($> != 0 and $< != 0)
|
13
|
+
{
|
14
|
+
print STDERR "Only root wants to run start-memcached.\n";
|
15
|
+
exit;
|
16
|
+
}
|
17
|
+
|
18
|
+
my $params; my $etchandle; my $etcfile = "<%=deploy_to%>/memcached/memcached/etc/init.d/memcached.conf";
|
19
|
+
|
20
|
+
# This script assumes that memcached is located at /usr/bin/memcached, and
|
21
|
+
# that the pidfile is writable at /var/run/memcached.pid
|
22
|
+
|
23
|
+
my $memcached = "/usr/local/bin/memcached";
|
24
|
+
my $pidfile = "<%=memcached_run_dir%>/memcached_<%=memcached_port%>.pid";
|
25
|
+
|
26
|
+
# If we don't get a valid logfile parameter in the /etc/memcached.conf file,
|
27
|
+
# we'll just throw away all of our in-daemon output. We need to re-tie it so
|
28
|
+
# that non-bash shells will not hang on logout. Thanks to Michael Renner for
|
29
|
+
# the tip
|
30
|
+
# my $fd_reopened = "/dev/null";
|
31
|
+
my $fd_reopened = "<%=memcached_log_dir%>/memcached_<%=memcached_port%>.log";
|
32
|
+
|
33
|
+
sub handle_logfile
|
34
|
+
{
|
35
|
+
my ($logfile) = @_;
|
36
|
+
$fd_reopened = $logfile;
|
37
|
+
}
|
38
|
+
|
39
|
+
sub reopen_logfile
|
40
|
+
{
|
41
|
+
my ($logfile) = @_;
|
42
|
+
|
43
|
+
open *STDERR, ">>$logfile";
|
44
|
+
open *STDOUT, ">>$logfile";
|
45
|
+
open *STDIN, ">>/dev/null";
|
46
|
+
$fd_reopened = $logfile;
|
47
|
+
}
|
48
|
+
|
49
|
+
# This is set up in place here to support other non -[a-z] directives
|
50
|
+
|
51
|
+
my $conf_directives = {
|
52
|
+
"logfile" => \&handle_logfile,
|
53
|
+
};
|
54
|
+
|
55
|
+
if(open $etchandle, $etcfile)
|
56
|
+
{
|
57
|
+
foreach my $line (<$etchandle>)
|
58
|
+
{
|
59
|
+
$line ||= "";
|
60
|
+
$line =~ s/\#.*//g;
|
61
|
+
$line =~ s/\s+$//g;
|
62
|
+
$line =~ s/^\s+//g;
|
63
|
+
next unless $line;
|
64
|
+
next if $line =~ /^\-[dh]/;
|
65
|
+
|
66
|
+
if($line =~ /^[^\-]/)
|
67
|
+
{
|
68
|
+
my ($directive, $arg) = $line =~ /^(.*?)\s+(.*)/;
|
69
|
+
$conf_directives->{$directive}->($arg);
|
70
|
+
next;
|
71
|
+
}
|
72
|
+
|
73
|
+
push @$params, $line;
|
74
|
+
}
|
75
|
+
|
76
|
+
}else{
|
77
|
+
$params = [];
|
78
|
+
}
|
79
|
+
|
80
|
+
push @$params, "-u root" unless(grep "-u", @$params);
|
81
|
+
$params = join " ", @$params;
|
82
|
+
|
83
|
+
if(-e $pidfile)
|
84
|
+
{
|
85
|
+
open PIDHANDLE, "$pidfile";
|
86
|
+
my $localpid = <PIDHANDLE>;
|
87
|
+
close PIDHANDLE;
|
88
|
+
|
89
|
+
chomp $localpid;
|
90
|
+
if(-d "/proc/$localpid")
|
91
|
+
{
|
92
|
+
print STDERR "memcached is already running.\n";
|
93
|
+
exit;
|
94
|
+
}else{
|
95
|
+
`rm -f $localpid`;
|
96
|
+
}
|
97
|
+
|
98
|
+
}
|
99
|
+
|
100
|
+
my $pid = fork();
|
101
|
+
|
102
|
+
if($pid == 0)
|
103
|
+
{
|
104
|
+
reopen_logfile($fd_reopened);
|
105
|
+
exec "$memcached $params";
|
106
|
+
exit(0);
|
107
|
+
|
108
|
+
}else{
|
109
|
+
if(open PIDHANDLE,">$pidfile")
|
110
|
+
{
|
111
|
+
print PIDHANDLE $pid;
|
112
|
+
close PIDHANDLE;
|
113
|
+
}else{
|
114
|
+
|
115
|
+
print STDERR "Can't write pidfile to $pidfile.\n";
|
116
|
+
}
|
117
|
+
}
|
118
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Listen 2813
|
2
|
+
<VirtualHost *:2813>
|
3
|
+
ServerName <%= domain %>
|
4
|
+
|
5
|
+
DocumentRoot <%= "#{deploy_to}/munin/html" %>
|
6
|
+
|
7
|
+
<Directory <%= "#{deploy_to}/munin/html" %>>
|
8
|
+
Options FollowSymLinks
|
9
|
+
AllowOverride None
|
10
|
+
Order allow,deny
|
11
|
+
Allow from all
|
12
|
+
AuthName "Munin Access"
|
13
|
+
AuthType Basic
|
14
|
+
AuthUserFile <%= "#{deploy_to}/munin/htpasswd.users"%>
|
15
|
+
Require valid-user
|
16
|
+
</Directory>
|
17
|
+
|
18
|
+
ErrorLog /var/log/munin-error_log
|
19
|
+
CustomLog /var/log/munin-access_log combined
|
20
|
+
</VirtualHost>
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# Example configuration file for Munin, generated by 'make build'
|
2
|
+
|
3
|
+
# The next three variables specifies where the location of the RRD
|
4
|
+
# databases, the HTML output, and the logs, severally. They all
|
5
|
+
# must be writable by the user running munin-cron.
|
6
|
+
dbdir /var/lib/munin
|
7
|
+
htmldir <%= deploy_to %>/munin/html
|
8
|
+
logdir /var/log/munin
|
9
|
+
rundir /var/run/munin
|
10
|
+
|
11
|
+
# Where to look for the HTML templates
|
12
|
+
tmpldir /etc/munin/templates
|
13
|
+
|
14
|
+
# Make graphs show values per minute instead of per second
|
15
|
+
#graph_period minute
|
16
|
+
|
17
|
+
# Drop somejuser@fnord.comm and anotheruser@blibb.comm an email everytime
|
18
|
+
# something changes (OK -> WARNING, CRITICAL -> OK, etc)
|
19
|
+
#contact.someuser.command mail -s "Munin notification" somejuser@fnord.comm
|
20
|
+
#contact.anotheruser.command mail -s "Munin notification" anotheruser@blibb.comm
|
21
|
+
#
|
22
|
+
# For those with Nagios, the following might come in handy. In addition,
|
23
|
+
# the services must be defined in the Nagios server as well.
|
24
|
+
#contact.nagios.command /usr/sbin/send_nsca -H nagios.host.com -c /etc/send_nsca.cfg
|
25
|
+
|
26
|
+
# a simple host tree
|
27
|
+
[localhost.localdomain]
|
28
|
+
address 127.0.0.1
|
29
|
+
use_node_name yes
|
30
|
+
|
31
|
+
#
|
32
|
+
# A more complex example of a host tree
|
33
|
+
#
|
34
|
+
## First our "normal" host.
|
35
|
+
# [fii.foo.com]
|
36
|
+
# address foo
|
37
|
+
#
|
38
|
+
## Then our other host...
|
39
|
+
# [fay.foo.com]
|
40
|
+
# address fay
|
41
|
+
#
|
42
|
+
## Then we want totals...
|
43
|
+
# [foo.com;Totals] #Force it into the "foo.com"-domain...
|
44
|
+
# update no # Turn off data-fetching for this "host".
|
45
|
+
#
|
46
|
+
# # The graph "load1". We want to see the loads of both machines...
|
47
|
+
# # "fii=fii.foo.com:load.load" means "label=machine:graph.field"
|
48
|
+
# load1.graph_title Loads side by side
|
49
|
+
# load1.graph_order fii=fii.foo.com:load.load fay=fay.foo.com:load.load
|
50
|
+
#
|
51
|
+
# # The graph "load2". Now we want them stacked on top of each other.
|
52
|
+
# load2.graph_title Loads on top of each other
|
53
|
+
# load2.dummy_field.stack fii=fii.foo.com:load.load fay=fay.foo.com:load.load
|
54
|
+
# load2.dummy_field.draw AREA # We want area instead the default LINE2.
|
55
|
+
# load2.dummy_field.label dummy # This is needed. Silly, really.
|
56
|
+
#
|
57
|
+
# # The graph "load3". Now we want them summarised into one field
|
58
|
+
# load3.graph_title Loads summarised
|
59
|
+
# load3.combined_loads.sum fii.foo.com:load.load fay.foo.com:load.load
|
60
|
+
# load3.combined_loads.label Combined loads # Must be set, as this is
|
61
|
+
# # not a dummy field!
|
62
|
+
#
|
63
|
+
## ...and on a side note, I want them listen in another order (default is
|
64
|
+
## alphabetically)
|
65
|
+
#
|
66
|
+
# # Since [foo.com] would be interpreted as a host in the domain "com", we
|
67
|
+
# # specify that this is a domain by adding a semicolon.
|
68
|
+
# [foo.com;]
|
69
|
+
# node_order Totals fii.foo.com fay.foo.com
|
70
|
+
#
|
@@ -0,0 +1,24 @@
|
|
1
|
+
server {
|
2
|
+
listen 2813;
|
3
|
+
server_name <%= domain %>;
|
4
|
+
root <%= deploy_to %>/munin/html;
|
5
|
+
access_log <%= deploy_to %>/shared/log/munin-access.log;
|
6
|
+
error_log <%= deploy_to %>/shared/log/munin-error.log;
|
7
|
+
|
8
|
+
location / {
|
9
|
+
# auth_basic "Munin Access";
|
10
|
+
# auth_basic_user_file <%= "#{deploy_to}/munin/htpasswd.users"%>;
|
11
|
+
|
12
|
+
proxy_set_header X-Real-IP $remote_addr;
|
13
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
14
|
+
proxy_set_header Host $http_host;
|
15
|
+
proxy_redirect false;
|
16
|
+
|
17
|
+
if (-f $request_filename/index.html) {
|
18
|
+
rewrite (.*) $1/index.html break;
|
19
|
+
}
|
20
|
+
if (-f $request_filename.html) {
|
21
|
+
rewrite (.*) $1.html break;
|
22
|
+
}
|
23
|
+
}
|
24
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
PATH=/usr/local/bin:/usr/bin:/bin:/opt/ruby-enterprise/bin
|
2
|
+
|
3
|
+
## every 30 minutes
|
4
|
+
## 1,31 * * * * root sh -c 'cd <%=deploy_to%>/current/; rake RAKETASK RAILS_ENV=<%=rails_env%> >> <%=rakecron_log_dir%>/<%=application%>-TASK.log 2>&1'
|
5
|
+
## every day at 4am
|
6
|
+
## 1 4 * * * root sh -c 'cd <%=deploy_to%>/current/; rake RAKETASK RAILS_ENV=<%=rails_env%> >> <%=rakecron_log_dir%>/<%=application%>-TASK.log 2>&1'
|
7
|
+
## every day at 4am (except sundays)
|
8
|
+
## 1 4 * * 1-6 root sh -c 'cd <%=deploy_to%>/current/; rake RAKETASK RAILS_ENV=<%=rails_env%> >> <%=rakecron_log_dir%>/<%=application%>-TASK.log 2>&1'
|
9
|
+
## on a sunday
|
10
|
+
## 1 4 * * 7 root sh -c 'cd <%=deploy_to%>/current/; rake RAKETASK RAILS_ENV=<%=rails_env%> >> <%=rakecron_log_dir%>/<%=application%>-TASK.log 2>&1'
|
11
|
+
## every 3 minutes
|
12
|
+
## */3 * * * * root sh -c 'cd <%=deploy_to%>/current/; rake RAKETASK RAILS_ENV=<%=rails_env%> >> <%=rakecron_log_dir%>/<%=application%>-TASK.log 2>&1'
|