crazycode-cap-recipes 0.3.37
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/LICENSE +20 -0
- data/README.textile +586 -0
- data/Rakefile +57 -0
- data/VERSION.yml +5 -0
- data/bin/cap-recipes +4 -0
- data/cap-recipes.gemspec +128 -0
- data/examples/advanced/deploy.rb +39 -0
- data/examples/advanced/deploy/experimental.rb +14 -0
- data/examples/advanced/deploy/production.rb +20 -0
- data/examples/simple/deploy.rb +36 -0
- data/lib/cap_recipes.rb +1 -0
- data/lib/cap_recipes/tasks/apache.rb +1 -0
- data/lib/cap_recipes/tasks/apache/install.rb +16 -0
- data/lib/cap_recipes/tasks/apache/manage.rb +26 -0
- data/lib/cap_recipes/tasks/aptitude.rb +1 -0
- data/lib/cap_recipes/tasks/aptitude/manage.rb +32 -0
- data/lib/cap_recipes/tasks/backgroundrb.rb +1 -0
- data/lib/cap_recipes/tasks/backgroundrb/hooks.rb +5 -0
- data/lib/cap_recipes/tasks/backgroundrb/manage.rb +64 -0
- data/lib/cap_recipes/tasks/bundler.rb +1 -0
- data/lib/cap_recipes/tasks/bundler/manage.rb +31 -0
- data/lib/cap_recipes/tasks/delayed_job.rb +1 -0
- data/lib/cap_recipes/tasks/delayed_job/hooks.rb +5 -0
- data/lib/cap_recipes/tasks/delayed_job/manage.rb +34 -0
- data/lib/cap_recipes/tasks/ec2/install.rb +32 -0
- data/lib/cap_recipes/tasks/ec2/manage.rb +32 -0
- data/lib/cap_recipes/tasks/gitosis.rb +1 -0
- data/lib/cap_recipes/tasks/gitosis/install.rb +58 -0
- data/lib/cap_recipes/tasks/gitosis/manage.rb +3 -0
- data/lib/cap_recipes/tasks/hudson.rb +1 -0
- data/lib/cap_recipes/tasks/hudson/manage.rb +33 -0
- data/lib/cap_recipes/tasks/jetty.rb +1 -0
- data/lib/cap_recipes/tasks/jetty/install.rb +33 -0
- data/lib/cap_recipes/tasks/jetty/manage.rb +34 -0
- data/lib/cap_recipes/tasks/jetty/web.rb +98 -0
- data/lib/cap_recipes/tasks/juggernaut.rb +3 -0
- data/lib/cap_recipes/tasks/juggernaut/hooks.rb +4 -0
- data/lib/cap_recipes/tasks/juggernaut/manage.rb +56 -0
- data/lib/cap_recipes/tasks/maven.rb +85 -0
- data/lib/cap_recipes/tasks/memcache.rb +3 -0
- data/lib/cap_recipes/tasks/memcache/hooks.rb +5 -0
- data/lib/cap_recipes/tasks/memcache/install.rb +15 -0
- data/lib/cap_recipes/tasks/memcache/manage.rb +37 -0
- data/lib/cap_recipes/tasks/mongodb.rb +1 -0
- data/lib/cap_recipes/tasks/mongodb/install.rb +137 -0
- data/lib/cap_recipes/tasks/mongodb/manage.rb +27 -0
- data/lib/cap_recipes/tasks/passenger.rb +1 -0
- data/lib/cap_recipes/tasks/passenger/install.rb +72 -0
- data/lib/cap_recipes/tasks/passenger/manage.rb +23 -0
- data/lib/cap_recipes/tasks/rails.rb +1 -0
- data/lib/cap_recipes/tasks/rails/hooks.rb +6 -0
- data/lib/cap_recipes/tasks/rails/manage.rb +51 -0
- data/lib/cap_recipes/tasks/ruby.rb +1 -0
- data/lib/cap_recipes/tasks/ruby/install.rb +16 -0
- data/lib/cap_recipes/tasks/rubygems.rb +1 -0
- data/lib/cap_recipes/tasks/rubygems/install.rb +22 -0
- data/lib/cap_recipes/tasks/rubygems/manage.rb +43 -0
- data/lib/cap_recipes/tasks/templates/hudson.erb +85 -0
- data/lib/cap_recipes/tasks/templates/mongod.conf.erb +89 -0
- data/lib/cap_recipes/tasks/templates/mongodb.init.erb +73 -0
- data/lib/cap_recipes/tasks/templates/mongodb.repo.erb +4 -0
- data/lib/cap_recipes/tasks/templates/mongos.init.erb +69 -0
- data/lib/cap_recipes/tasks/templates/tomcat.erb +95 -0
- data/lib/cap_recipes/tasks/thinking_sphinx.rb +1 -0
- data/lib/cap_recipes/tasks/thinking_sphinx/hooks.rb +4 -0
- data/lib/cap_recipes/tasks/thinking_sphinx/install.rb +17 -0
- data/lib/cap_recipes/tasks/thinking_sphinx/manage.rb +65 -0
- data/lib/cap_recipes/tasks/tomcat.rb +1 -0
- data/lib/cap_recipes/tasks/tomcat/install.rb +43 -0
- data/lib/cap_recipes/tasks/tomcat/manage.rb +34 -0
- data/lib/cap_recipes/tasks/tomcat/war.rb +98 -0
- data/lib/cap_recipes/tasks/utilities.rb +172 -0
- data/lib/cap_recipes/tasks/whenever.rb +1 -0
- data/lib/cap_recipes/tasks/whenever/hooks.rb +5 -0
- data/lib/cap_recipes/tasks/whenever/manage.rb +8 -0
- data/lib/cap_recipes/tasks/yum.rb +1 -0
- data/lib/cap_recipes/tasks/yum/manage.rb +30 -0
- data/lib/capify.rb +35 -0
- data/lib/templates/Capfile.tt +4 -0
- data/lib/templates/deploy.rb.tt +30 -0
- data/spec/cap/all/Capfile +2 -0
- data/spec/cap/helper.rb +3 -0
- data/spec/cap_recipes_spec.rb +56 -0
- data/spec/spec_helper.rb +37 -0
- data/specs.watchr +35 -0
- metadata +155 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Dir[File.join(File.dirname(__FILE__), 'ruby/*.rb')].sort.each { |lib| require lib }
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../utilities')
|
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + '/../aptitude/manage')
|
|
3
|
+
|
|
4
|
+
Capistrano::Configuration.instance(true).load do
|
|
5
|
+
|
|
6
|
+
namespace :ruby do
|
|
7
|
+
|
|
8
|
+
desc "install ruby"
|
|
9
|
+
task :setup, :roles => :app do
|
|
10
|
+
utilities.apt_install %w[ruby ri rdoc ruby1.8-dev irb1.8 libreadline-ruby1.8
|
|
11
|
+
libruby1.8 rdoc1.8 ri1.8 ruby1.8 irb libopenssl-ruby libopenssl-ruby1.8]
|
|
12
|
+
end
|
|
13
|
+
before "ruby:setup", "aptitude:updates"
|
|
14
|
+
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Dir[File.join(File.dirname(__FILE__), 'rubygems/*.rb')].sort.each { |lib| require lib }
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Capistrano::Configuration.instance(true).load do
|
|
2
|
+
set :rubygems_version, "1.3.5"
|
|
3
|
+
|
|
4
|
+
namespace :rubygems do
|
|
5
|
+
before "rubygems:setup", "ruby:setup"
|
|
6
|
+
|
|
7
|
+
desc "install rubygems"
|
|
8
|
+
task :setup, :roles => :app do
|
|
9
|
+
run "wget http://rubyforge.org/frs/download.php/60718/rubygems-#{rubygems_version}.tgz"
|
|
10
|
+
run "tar xvzf rubygems-#{rubygems_version}.tgz"
|
|
11
|
+
run "cd rubygems-#{rubygems_version}; sudo ruby setup.rb"
|
|
12
|
+
run "#{sudo} rm /usr/bin/gem; #{sudo} ln -s /usr/bin/gem1.8 /usr/bin/gem"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
desc "cleanup the files"
|
|
16
|
+
task :cleanup do
|
|
17
|
+
run "cd; rm -rf rubygems-#{rubygems_version}; rm -rf rubygems-#{rubygems_version}.*"
|
|
18
|
+
end
|
|
19
|
+
after "rubygems:setup", "rubygems:cleanup"
|
|
20
|
+
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../utilities')
|
|
2
|
+
|
|
3
|
+
Capistrano::Configuration.instance(true).load do
|
|
4
|
+
set :rubygem_paths, '/usr/bin/gem'
|
|
5
|
+
|
|
6
|
+
namespace :rubygems do
|
|
7
|
+
desc "Performs a rubygems upgrade, updates all gems and cleans up old ones"
|
|
8
|
+
task :full_update, :roles => :app do
|
|
9
|
+
rubygems.upgrade
|
|
10
|
+
rubygems.update
|
|
11
|
+
rubygems.cleanup
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
desc "Upgrades the rubygem package installation"
|
|
15
|
+
task :upgrade, :roles => :app do
|
|
16
|
+
Array(rubygem_paths).each { |path| sudo "#{path} update --system" }
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
desc "Updates all installed gems on app servers"
|
|
20
|
+
task :update, :roles => :app do
|
|
21
|
+
Array(rubygem_paths).each { |path| sudo "#{path} update" }
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
desc "Removes old gems which have been outdated"
|
|
25
|
+
task :cleanup, :roles => :app do
|
|
26
|
+
Array(rubygem_paths).each { |path| sudo "#{path} cleanup" }
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
desc "Install a gem on the app servers"
|
|
30
|
+
task :install, :roles => :app do
|
|
31
|
+
gem_name = utilities.ask "Enter the name of the gem you'd like to install:"
|
|
32
|
+
logger.info "trying to install '#{gem_name}'"
|
|
33
|
+
Array(rubygem_paths).each {|path| sudo "#{path} install #{gem_name} --no-ri --no-rdoc" }
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
desc "Uninstall a gem from app servers"
|
|
37
|
+
task :uninstall, :roles => :app do
|
|
38
|
+
gem_name = utilities.ask "Enter the name of the gem you'd like to remove:"
|
|
39
|
+
logger.info "trying to remove '#{gem_name}'"
|
|
40
|
+
Array(rubygem_paths).each { |path| sudo "#{path} uninstall #{gem_name} -x" }
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#! /bin/bash
|
|
2
|
+
#
|
|
3
|
+
# hudson Start/Stop the Hudson Continuous Integration server.
|
|
4
|
+
#
|
|
5
|
+
# chkconfig: 345 91 10
|
|
6
|
+
# description: Hudson is a Continuous Integration server. \
|
|
7
|
+
# It monitors a source code repository and triggers builds \
|
|
8
|
+
# when it detects any changes. See https://hudson.dev.java.net/ \
|
|
9
|
+
# for more details.
|
|
10
|
+
# processname: hudson
|
|
11
|
+
# pidfile: /var/run/hudson.pid
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# Source function library.
|
|
15
|
+
. /etc/rc.d/init.d/functions
|
|
16
|
+
|
|
17
|
+
# Get config.
|
|
18
|
+
. /etc/sysconfig/network
|
|
19
|
+
|
|
20
|
+
# Check that networking is up.
|
|
21
|
+
[ "${NETWORKING}" = "no" ] && exit 0
|
|
22
|
+
|
|
23
|
+
startup=/usr/local/bin/start-hudson.sh
|
|
24
|
+
shutdown=/usr/local/bin/stop-hudson.sh
|
|
25
|
+
|
|
26
|
+
HUDSON_WAR=/opt/hudson.war
|
|
27
|
+
HUDSON_LOG=/home/tomcat/hudson.log
|
|
28
|
+
HUDSON_HOME=/opt/hudson
|
|
29
|
+
|
|
30
|
+
export JAVA_HOME=/usr/java/jdk1.6.0
|
|
31
|
+
HUDSON_USER=tomcat
|
|
32
|
+
export HUDSON_HOME=/opt/hudson
|
|
33
|
+
JAVA=$JAVA_HOME/bin/java
|
|
34
|
+
|
|
35
|
+
start(){
|
|
36
|
+
echo -n $"Starting Hudson service: "
|
|
37
|
+
su - $HUDSON_USER -c "nohup nice $JAVA -DHUDSON_HOME=$HUDSON_HOME -jar $HUDSON_WAR --httpPort=8099 --logfile $HUDSON_LOG &"
|
|
38
|
+
echo "run..."
|
|
39
|
+
RETVAL=$?
|
|
40
|
+
echo
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
stop(){
|
|
44
|
+
action $"Stopping Hudson service: "
|
|
45
|
+
su - $HUDSON_USER -c "kill `ps -ef | grep hudson.war | grep -v grep | awk '{ print $2 }'`"
|
|
46
|
+
|
|
47
|
+
RETVAL=$?
|
|
48
|
+
echo
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
status(){
|
|
52
|
+
numproc=`ps -ef | grep hudson.war | grep -v "grep hudson.war" | wc -l`
|
|
53
|
+
if [ $numproc -gt 0 ]; then
|
|
54
|
+
echo "Hudson is running..."
|
|
55
|
+
else
|
|
56
|
+
echo "Hudson is stopped..."
|
|
57
|
+
fi
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
restart(){
|
|
61
|
+
stop
|
|
62
|
+
start
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
# See how we were called.
|
|
67
|
+
case "$1" in
|
|
68
|
+
start)
|
|
69
|
+
start
|
|
70
|
+
;;
|
|
71
|
+
stop)
|
|
72
|
+
stop
|
|
73
|
+
;;
|
|
74
|
+
status)
|
|
75
|
+
status
|
|
76
|
+
;;
|
|
77
|
+
restart)
|
|
78
|
+
restart
|
|
79
|
+
;;
|
|
80
|
+
*)
|
|
81
|
+
echo $"Usage: $0 {start|stop|status|restart}"
|
|
82
|
+
exit 1
|
|
83
|
+
esac
|
|
84
|
+
|
|
85
|
+
exit 0
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# mongo.conf
|
|
2
|
+
<% unless mongodb_is_configsvr %>
|
|
3
|
+
replSet=<%= mongodb_nodename %>
|
|
4
|
+
<% end %>
|
|
5
|
+
rest=false
|
|
6
|
+
<% if mongodb_is_configsvr %>
|
|
7
|
+
configsvr=true
|
|
8
|
+
<% end %>
|
|
9
|
+
#where to log
|
|
10
|
+
logpath=/var/log/mongo/<%= mongodb_name %>.log
|
|
11
|
+
|
|
12
|
+
logappend=true
|
|
13
|
+
|
|
14
|
+
oplogSize=20000
|
|
15
|
+
|
|
16
|
+
# fork and run in background
|
|
17
|
+
fork=true
|
|
18
|
+
|
|
19
|
+
port=<%= mongodb_port %>
|
|
20
|
+
|
|
21
|
+
dbpath=<%= mongodb_data_path %>
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
# Enables periodic logging of CPU utilization and I/O wait
|
|
25
|
+
#cpu = true
|
|
26
|
+
|
|
27
|
+
# Turn on/off security. Off is currently the default
|
|
28
|
+
#noauth = true
|
|
29
|
+
#auth = true
|
|
30
|
+
|
|
31
|
+
# Verbose logging output.
|
|
32
|
+
#verbose = true
|
|
33
|
+
|
|
34
|
+
# Inspect all client data for validity on receipt (useful for
|
|
35
|
+
# developing drivers)
|
|
36
|
+
#objcheck = true
|
|
37
|
+
|
|
38
|
+
# Enable db quota management
|
|
39
|
+
#quota = true
|
|
40
|
+
|
|
41
|
+
# Set oplogging level where n is
|
|
42
|
+
# 0=off (default)
|
|
43
|
+
# 1=W
|
|
44
|
+
# 2=R
|
|
45
|
+
# 3=both
|
|
46
|
+
# 7=W+some reads
|
|
47
|
+
#oplog = 0
|
|
48
|
+
|
|
49
|
+
# Diagnostic/debugging option
|
|
50
|
+
#nocursors = true
|
|
51
|
+
|
|
52
|
+
# Ignore query hints
|
|
53
|
+
#nohints = true
|
|
54
|
+
|
|
55
|
+
# Disable the HTTP interface (Defaults to localhost:27018).
|
|
56
|
+
#nohttpinterface = true
|
|
57
|
+
|
|
58
|
+
# Turns off server-side scripting. This will result in greatly limited
|
|
59
|
+
# functionality
|
|
60
|
+
#noscripting = true
|
|
61
|
+
|
|
62
|
+
# Turns off table scans. Any query that would do a table scan fails.
|
|
63
|
+
#notablescan = true
|
|
64
|
+
|
|
65
|
+
# Disable data file preallocation.
|
|
66
|
+
#noprealloc = true
|
|
67
|
+
|
|
68
|
+
# Specify .ns file size for new databases.
|
|
69
|
+
# nssize = <size>
|
|
70
|
+
|
|
71
|
+
# Accout token for Mongo monitoring server.
|
|
72
|
+
#mms-token = <token>
|
|
73
|
+
|
|
74
|
+
# Server name for Mongo monitoring server.
|
|
75
|
+
#mms-name = <server-name>
|
|
76
|
+
|
|
77
|
+
# Ping interval for Mongo monitoring server.
|
|
78
|
+
#mms-interval = <seconds>
|
|
79
|
+
|
|
80
|
+
# Replication Options
|
|
81
|
+
|
|
82
|
+
# in replicated mongo databases, specify here whether this is a slave or master
|
|
83
|
+
#slave = true
|
|
84
|
+
#source = master.example.com
|
|
85
|
+
# Slave only: specify a single database to replicate
|
|
86
|
+
#only = master.example.com
|
|
87
|
+
# or
|
|
88
|
+
#master = true
|
|
89
|
+
#source = slave.example.com
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# <%= mongodb_name %> - Startup script for mongod
|
|
4
|
+
|
|
5
|
+
# chkconfig: 35 85 15
|
|
6
|
+
# description: Mongo is a scalable, document-oriented database.
|
|
7
|
+
# processname: <%= mongodb_name %>
|
|
8
|
+
# config: /etc/<%= mongodb_name %>.conf
|
|
9
|
+
# pidfile: /var/run/mongo/<%= mongodb_name %>.pid
|
|
10
|
+
|
|
11
|
+
. /etc/rc.d/init.d/functions
|
|
12
|
+
|
|
13
|
+
# things from <%= mongodb_name %>.conf get there by mongod reading it
|
|
14
|
+
|
|
15
|
+
OPTIONS=" -f /etc/<%= mongodb_name %>.conf"
|
|
16
|
+
SYSCONFIG="/etc/sysconfig/mongod"
|
|
17
|
+
|
|
18
|
+
mongod=${MONGOD-/usr/bin/mongod}
|
|
19
|
+
|
|
20
|
+
MONGO_USER=mongod
|
|
21
|
+
MONGO_GROUP=mongod
|
|
22
|
+
|
|
23
|
+
. "$SYSCONFIG" || true
|
|
24
|
+
|
|
25
|
+
start()
|
|
26
|
+
{
|
|
27
|
+
echo -n $"Starting mongod: "
|
|
28
|
+
daemon --user "$MONGO_USER" $mongod $OPTIONS
|
|
29
|
+
RETVAL=$?
|
|
30
|
+
echo
|
|
31
|
+
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/<%= mongodb_name %>
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
stop()
|
|
35
|
+
{
|
|
36
|
+
echo -n $"Stopping mongod: "
|
|
37
|
+
killproc -p <%= mongodb_data_path %>/mongod.lock -t30 -TERM /usr/bin/mongod
|
|
38
|
+
RETVAL=$?
|
|
39
|
+
echo
|
|
40
|
+
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/<%= mongodb_name %>
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
restart () {
|
|
44
|
+
stop
|
|
45
|
+
start
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
ulimit -n 12000
|
|
49
|
+
RETVAL=0
|
|
50
|
+
|
|
51
|
+
case "$1" in
|
|
52
|
+
start)
|
|
53
|
+
start
|
|
54
|
+
;;
|
|
55
|
+
stop)
|
|
56
|
+
stop
|
|
57
|
+
;;
|
|
58
|
+
restart|reload|force-reload)
|
|
59
|
+
restart
|
|
60
|
+
;;
|
|
61
|
+
condrestart)
|
|
62
|
+
[ -f /var/lock/subsys/<%= mongodb_name %> ] && restart || :
|
|
63
|
+
;;
|
|
64
|
+
status)
|
|
65
|
+
status $mongod
|
|
66
|
+
RETVAL=$?
|
|
67
|
+
;;
|
|
68
|
+
*)
|
|
69
|
+
echo "Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
|
|
70
|
+
RETVAL=1
|
|
71
|
+
esac
|
|
72
|
+
|
|
73
|
+
exit $RETVAL
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# <%= mongos_name %> - Startup script for mongos
|
|
4
|
+
|
|
5
|
+
# chkconfig: 35 85 15
|
|
6
|
+
# description: <%= Mongos_name %>.
|
|
7
|
+
# processname: mongos
|
|
8
|
+
# pidfile: /tmp/<%= mongos_name %>.pid
|
|
9
|
+
|
|
10
|
+
. /etc/rc.d/init.d/functions
|
|
11
|
+
|
|
12
|
+
# things from mongos.conf get there by mongod reading it
|
|
13
|
+
|
|
14
|
+
OPTIONS=" --configdb <%= mongos_config_db %> --logpath <%= mongos_log_path %> --pidfilepath /tmp/<%= mongos_name %>.pid"
|
|
15
|
+
|
|
16
|
+
mongos=${MONGOS-/usr/bin/mongos}
|
|
17
|
+
|
|
18
|
+
MONGO_USER=mongod
|
|
19
|
+
MONGO_GROUP=mongod
|
|
20
|
+
|
|
21
|
+
start()
|
|
22
|
+
{
|
|
23
|
+
echo -n $"Starting <%= mongos_name %>: "
|
|
24
|
+
daemon --user "$MONGO_USER" $mongos $OPTIONS
|
|
25
|
+
RETVAL=$?
|
|
26
|
+
echo
|
|
27
|
+
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/<%= mongos_name %>
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
stop()
|
|
31
|
+
{
|
|
32
|
+
echo -n $"Stopping <%= mongos_name %>: "
|
|
33
|
+
killproc -p /tmp/<%= mongos_name %>.pid -t30 -TERM /usr/bin/mongos
|
|
34
|
+
RETVAL=$?
|
|
35
|
+
echo
|
|
36
|
+
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/<%= mongos_name %>
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
restart () {
|
|
40
|
+
stop
|
|
41
|
+
start
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
ulimit -n 12000
|
|
45
|
+
RETVAL=0
|
|
46
|
+
|
|
47
|
+
case "$1" in
|
|
48
|
+
start)
|
|
49
|
+
start
|
|
50
|
+
;;
|
|
51
|
+
stop)
|
|
52
|
+
stop
|
|
53
|
+
;;
|
|
54
|
+
restart|reload|force-reload)
|
|
55
|
+
restart
|
|
56
|
+
;;
|
|
57
|
+
condrestart)
|
|
58
|
+
[ -f /var/lock/subsys/<%= mongos_name %> ] && restart || :
|
|
59
|
+
;;
|
|
60
|
+
status)
|
|
61
|
+
status $mongos
|
|
62
|
+
RETVAL=$?
|
|
63
|
+
;;
|
|
64
|
+
*)
|
|
65
|
+
echo "Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}"
|
|
66
|
+
RETVAL=1
|
|
67
|
+
esac
|
|
68
|
+
|
|
69
|
+
exit $RETVAL
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
#
|
|
3
|
+
# Startup script for Jakarta Tomcat
|
|
4
|
+
#
|
|
5
|
+
# chkconfig: - 88 14
|
|
6
|
+
# description: Jakarta Tomcat Java Servlet/JSP Container
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
TOMCAT_HOME=<%= tomcat_home %>
|
|
10
|
+
TOMCAT_STOP=$TOMCAT_HOME/bin/shutdown.sh
|
|
11
|
+
TOMCAT_START=$TOMCAT_HOME/bin/startup.sh
|
|
12
|
+
|
|
13
|
+
#Necessary environment variables
|
|
14
|
+
export CATALINA_HOME=$TOMCAT_HOME
|
|
15
|
+
export JAVA_HOME=<%= java_home %>
|
|
16
|
+
TOMCAT_USER=<%= tomcat_user %>
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
# Source function library.
|
|
20
|
+
. /etc/rc.d/init.d/functions
|
|
21
|
+
|
|
22
|
+
# Source networking configuration.
|
|
23
|
+
. /etc/sysconfig/network
|
|
24
|
+
|
|
25
|
+
# Check that networking is up.
|
|
26
|
+
[ ${NETWORKING} = "no" ] && exit 0
|
|
27
|
+
|
|
28
|
+
#Check for tomcat script
|
|
29
|
+
if [ ! -f $TOMCAT_HOME/bin/catalina.sh ]
|
|
30
|
+
then
|
|
31
|
+
echo $TOMCAT_HOME/bin/catalina.sh
|
|
32
|
+
echo "Tomcat not available..."
|
|
33
|
+
exit
|
|
34
|
+
fi
|
|
35
|
+
|
|
36
|
+
start() {
|
|
37
|
+
echo "Starting Tomcat: "
|
|
38
|
+
#daemon $TOMCAT_START
|
|
39
|
+
/bin/su - $TOMCAT_USER -s /bin/bash -c $TOMCAT_START
|
|
40
|
+
echo
|
|
41
|
+
touch /var/lock/subsys/tomcatd
|
|
42
|
+
# We may need to sleep here so it will be up for apache
|
|
43
|
+
# sleep 5
|
|
44
|
+
#Instead should check to see if apache is up by looking for http.pid
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
stop() {
|
|
48
|
+
echo $"Shutting down Tomcat: "
|
|
49
|
+
echo $TOMCAT_STOP
|
|
50
|
+
/bin/su - $TOMCAT_USER -s /bin/bash -c $TOMCAT_STOP
|
|
51
|
+
rm -f /var/lock/subsys/tomcatd.pid
|
|
52
|
+
sleep 5
|
|
53
|
+
#如果不能关闭tomcat时(tomcat有时的bug),调用以下代码#
|
|
54
|
+
pid=`ps aux |grep "java"|grep "tomcat6"|grep -v "grep"|awk '{print $2}'`
|
|
55
|
+
if [ "$pid" = "" ] ; then
|
|
56
|
+
echo "tomcat is shutdown now!"
|
|
57
|
+
else
|
|
58
|
+
echo "force kill tomcat'pid $pid now"
|
|
59
|
+
kill -9 $pid
|
|
60
|
+
fi
|
|
61
|
+
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
status() {
|
|
65
|
+
ps ax --width=1000 | grep "tomcat6" | grep -v "grep" | grep "[o]rg.apache.catalina.startup.Bootstrap start" | awk '{printf $1 " "}' | wc | awk '{print $2}' >/tmp/tomcat_process_count.txt
|
|
66
|
+
read line < /tmp/tomcat_process_count.txt
|
|
67
|
+
if [ $line -gt 0 ]; then
|
|
68
|
+
echo -n "tomcatd ( pid "
|
|
69
|
+
ps ax --width=1000 | grep "tomcat6" | grep -v "grep" | grep "[o]rg.apache.catalina.startup.Bootstrap
|
|
70
|
+
start" | awk '{printf $1 " "}'
|
|
71
|
+
echo ") is running..."
|
|
72
|
+
else
|
|
73
|
+
echo "Tomcat is stopped"
|
|
74
|
+
fi
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
case "$1" in
|
|
78
|
+
start)
|
|
79
|
+
start
|
|
80
|
+
;;
|
|
81
|
+
stop)
|
|
82
|
+
stop
|
|
83
|
+
;;
|
|
84
|
+
restart)
|
|
85
|
+
stop
|
|
86
|
+
sleep 3
|
|
87
|
+
start
|
|
88
|
+
;;
|
|
89
|
+
status)
|
|
90
|
+
status
|
|
91
|
+
;;
|
|
92
|
+
*)
|
|
93
|
+
echo "Usage: /etc/init.d/tomcat {start|stop|restart|status}"
|
|
94
|
+
exit 1
|
|
95
|
+
esac
|