Permalink
Browse files

make start/stop consistent, only restart when bootstrap necessary, gr…

…aphite server upstart , fix redis bootstrap, fix resque_web bootstrap
  • Loading branch information...
1 parent e55d44c commit d66174542627a32bb35b11b69a549c52dd01cacc Matt Conway committed Jan 27, 2012
View
4 templates/apache/config/rubber/deploy-apache.rb
@@ -15,7 +15,7 @@
# rubber auto-roles don't get defined till after all tasks are defined
on :load do
rubber.serial_task self, :serial_restart, :roles => :apache do
- rsudo "service apache2 restart"
+ rsudo "service apache2 stop; service apache2 start"
end
rubber.serial_task self, :serial_reload, :roles => :apache do
rsudo "if ! ps ax | grep -v grep | grep -c apache2 &> /dev/null; then service apache2 start; else service apache2 reload; fi"
@@ -28,7 +28,7 @@
desc "Stops the apache web server"
task :stop, :roles => :apache do
- rsudo "service apache2 stop; exit 0"
+ rsudo "service apache2 stop || true"
end
desc "Starts the apache web server"
View
5 templates/collectd/config/rubber/deploy-collectd.rb
@@ -27,12 +27,13 @@
desc "Stop collectd system monitoring"
task :stop, :roles => :collectd do
- rsudo "service collectd stop; exit 0"
+ rsudo "service collectd stop || true"
end
desc "Restart collectd system monitoring"
task :restart, :roles => :collectd do
- rsudo "service collectd restart; sleep 5"
+ stop
+ start
end
desc "Restart collectd rubber plugin"
View
4 templates/elasticsearch/config/rubber/deploy-elasticsearch.rb
@@ -25,9 +25,9 @@
# on hosts in order to run rubber:config for bootstrapping the db
rubber.update_code_for_bootstrap
rubber.run_config(:file => "role/elasticsearch", :force => true, :deploy_path => release_path)
+
+ restart
end
-
- restart
end
task :start, :roles => :elasticsearch do
View
8 templates/graphite/config/rubber/deploy-graphite.rb
@@ -153,18 +153,18 @@
rubber.run_config(:file => "role/graphite_server", :force => true, :deploy_path => release_path)
- start
+ restart
end
end
desc "Start graphite system monitoring"
task :start, :roles => :graphite_server do
- rsudo "cd /opt/graphite/ && ./bin/carbon-cache.py start"
+ rsudo "service graphite-server start"
end
desc "Stop graphite system monitoring"
task :stop, :roles => :graphite_server do
- rsudo "cd /opt/graphite/ && ./bin/carbon-cache.py stop"
+ rsudo "service graphite-server stop || true"
end
desc "Restart graphite system monitoring"
@@ -239,7 +239,7 @@
desc "Stop graphite system monitoring"
task :stop, :roles => :graphite_web do
- rsudo "service apache2 stop; exit 0"
+ rsudo "service apache2 stop || true"
end
desc "Restart graphite system monitoring"
View
23 templates/graphite/config/rubber/role/graphite_server/graphite_server-upstart.conf
@@ -0,0 +1,23 @@
+<%
+ @path = "/etc/init/graphite-server.conf"
+ @backup = false
+%>
+description "graphite server"
+
+start on [2345]
+stop on runlevel [016]
+
+expect daemon
+
+script
+ cd <%= rubber_env.graphite_dir %>
+ exec ./bin/carbon-cache.py start
+end script
+
+post-start script
+ status graphite-server | head -n1 | awk '{print $NF}' > <%= rubber_env.graphite_server_pid_file %>
+end script
+
+post-stop script
+ rm -f <%= rubber_env.graphite_server_pid_file %>
+end script
View
2 templates/graphite/config/rubber/rubber-graphite.yml
@@ -1,3 +1,5 @@
+graphite_dir: "/opt/graphite"
+graphite_server_pid_file: /var/run/graphite-server.pid
graphite_server_port: 2003
graphite_web_port: 2080
View
7 templates/graylog/config/rubber/deploy-graylog.rb
@@ -24,9 +24,9 @@
if exists.strip.size == 0
rubber.update_code_for_bootstrap
rubber.run_config(:file => "role/graylog_server", :force => true, :deploy_path => release_path)
- end
- restart
+ restart
+ end
end
desc "Stops the graylog server"
@@ -82,8 +82,9 @@
# Create the Graylog Web admin account.
./script/rails runner "User.create(:login => '#{rubber_env.graylog_web_username}', :email => '#{rubber_env.graylog_web_email}', :password => '#{rubber_env.graylog_web_password}', :password_confirmation => '#{rubber_env.graylog_web_password}', :role => 'admin') if User.count == 0"
ENDSCRIPT
+
+ restart
end
- restart
end
desc "Stops the graylog web"
View
4 templates/haproxy/config/rubber/deploy-haproxy.rb
@@ -9,7 +9,7 @@
# rubber auto-roles don't get defined till after all tasks are defined
on :load do
rubber.serial_task self, :serial_restart, :roles => :haproxy do
- rsudo "service haproxy restart"
+ rsudo "service haproxy stop; service haproxy start"
end
rubber.serial_task self, :serial_reload, :roles => :haproxy do
rsudo "if ! ps ax | grep -v grep | grep -c haproxy &> /dev/null; then service haproxy start; else service haproxy reload; fi"
@@ -22,7 +22,7 @@
desc "Stops the haproxy server"
task :stop, :roles => :haproxy do
- rsudo "service haproxy stop; exit 0"
+ rsudo "service haproxy stop || true"
end
desc "Starts the haproxy server"
View
2 templates/monit/config/rubber/deploy-monit.rb
@@ -19,7 +19,7 @@
desc "Stop monit daemon monitoring"
task :stop, :roles => :monit do
- rsudo "service monit stop; exit 0"
+ rsudo "service monit stop || true"
end
desc "Restart monit daemon monitoring"
View
8 templates/monit/config/rubber/role/graphite_server/monit-graphite_server.conf
@@ -1,10 +1,8 @@
<%
@path = '/etc/monit/monit.d/monit-graphite_server.conf'
- pidfile = '/opt/graphite/storage/carbon-cache-a.pid'
%>
-check process graphite_server with pidfile <%= pidfile %>
+check process graphite_server with pidfile <%= rubber_env.graphite_server_pid_file %>
group graphite-<%= Rubber.env %>
- start program = "/bin/bash -l -c 'rm -f <%= pidfile %> && cd /opt/graphite && ./bin/carbon-cache.py start'"
- stop program = "/bin/bash -l -c 'cd /opt/graphite && ./bin/carbon-cache.py stop'"
+ start program = "/usr/bin/env service graphite-server start"
+ stop program = "/usr/bin/env service graphite-server stop"
if failed host <%= rubber_env.host %> port <%= rubber_env.graphite_server_port %> with timeout 10 seconds for 3 cycles then restart
-
View
5 templates/postgresql/config/rubber/deploy-postgresql.rb
@@ -124,14 +124,15 @@ def common_bootstrap
Stops the postgresql daemons
DESC
task :stop, :roles => [:postgresql_master, :postgresql_slave] do
- rsudo "#{rubber_env.postgresql_ctl} stop"
+ rsudo "#{rubber_env.postgresql_ctl} stop || true"
end
desc <<-DESC
Restarts the postgresql daemons
DESC
task :restart, :roles => [:postgresql_master, :postgresql_slave] do
- rsudo "#{rubber_env.postgresql_ctl} restart"
+ stop
+ start
end
end
View
5 templates/redis/config/rubber/deploy-redis.rb
@@ -48,10 +48,9 @@
# Gen just the conf for cassandra
rubber.run_config(:file => "role/redis", :force => true, :deploy_path => release_path)
-
- end
- restart
+ restart
+ end
end
desc "Stops the redis server"
View
4 templates/redis/config/rubber/role/redis/redis.conf
@@ -1,5 +1,5 @@
<%
- @path = '/etc/redis/redis.conf'
+ @path = rubber_env.redis_server_conf_file
@post = <<-SCRIPT
mkdir -p #{rubber_env.redis_db_dir}
chown -R redis:redis #{rubber_env.redis_db_dir}
@@ -58,7 +58,7 @@ loglevel notice
# Specify the log file name. Also 'stdout' can be used to force
# Redis to log on the standard output. Note that if you use standard
# output for logging but daemonize, logs will be sent to /dev/null
-logfile /var/log/redis/redis-server.log
+logfile <%= rubber_env.redis_server_log_file %>
# To enable logging to the system logger, just set 'syslog-enabled' to yes,
# and optionally update the other syslog parameters to suit your needs.
View
3 templates/redis/config/rubber/rubber-redis.yml
@@ -1,6 +1,7 @@
redis_server_version: 2.4.6
redis_server_pid_file: /var/run/redis-server.pid
-redis_server_conf_file: /etc/redis/redis.conf
+redis_server_conf_file: /etc/redis.conf
+redis_server_log_file: /var/log/redis-server.log
redis_server_port: 6379
redis_db_dir: /mnt/redis
View
24 templates/resque/config/rubber/deploy-resque.rb
@@ -164,29 +164,6 @@ def uid
namespace :web do
rubber.allow_optional_tasks(self)
- after "rubber:bootstrap", "rubber:resque:web:bootstrap"
-
- task :bootstrap, :roles => :resque_web do
- exists = capture("echo $(ls #{rubber_env.redis_db_dir} 2> /dev/null)")
- if exists.strip.size == 0
-
- rubber.sudo_script 'bootstrap_redis', <<-ENDSCRIPT
- mkdir -p #{rubber_env.redis_db_dir}
- chown -R redis:redis #{rubber_env.redis_db_dir}
- ENDSCRIPT
-
- # After everything installed on machines, we need the source tree
- # on hosts in order to run rubber:config for bootstrapping the db
- rubber.update_code_for_bootstrap
-
- # Gen just the conf for cassandra
- rubber.run_config(:file => "role/redis", :force => true, :deploy_path => release_path)
-
- end
-
- restart
- end
-
before "deploy:stop", "rubber:resque:web:stop"
after "deploy:start", "rubber:resque:web:start"
after "deploy:restart", "rubber:resque:web:restart"
@@ -204,7 +181,6 @@ def uid
desc "Restarts resque web tools"
task :restart, :roles => :resque_web do
stop
- sleep 2
start
end

0 comments on commit d661745

Please sign in to comment.