Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added/merged god, nginx, thin, and maintenance tasks. (github cluster…
…fuck) [git-p4: depot-paths = "//src/vlad/dev/": change = 4670]
- Loading branch information
Showing
5 changed files
with
147 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
require 'vlad' | ||
|
||
namespace :vlad do | ||
## God module for merb app server | ||
|
||
desc "Prepares application servers for deployment.".cleanup | ||
|
||
remote_task :setup_app, :roles => :app do | ||
|
||
end | ||
|
||
desc "Restart the app servers" | ||
|
||
remote_task :start_app, :roles => :app do | ||
run "god restart #{cluster_name}" | ||
end | ||
|
||
desc "Stop the app servers" | ||
|
||
remote_task :stop_app, :roles => :app do | ||
run "god stop #{cluster_name}" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
require 'vlad' | ||
|
||
namespace :vlad do | ||
## | ||
# Nginx web server on Gentoo/Debian init.d systems FIX | ||
|
||
set :web_command, "/etc/init.d/nginx" | ||
|
||
remote_task :setup_app, :roles => :web do | ||
config_file = "/etc/nginx/vhosts/#{application}_#{environment}.conf" | ||
raise "not yet... must review this code" | ||
run [ "sudo test -e #{config_file} || ", | ||
"sudo sh -c \"ruby ", | ||
" /etc/sliceconfig/install/interactive/nginx_config.rb ", | ||
"'#{app_domain}' '#{application}' '#{environment}' ", | ||
"'#{app_port}' '#{app_servers}' #{only_www ? 1 : 0} ", | ||
"> #{config_file}\"" | ||
].join(" ") | ||
end | ||
|
||
desc "(Re)Start the web servers" | ||
|
||
remote_task :start_web, :roles => :web do | ||
run "#{web_command} restart" | ||
# TODO: run %Q(sudo #{web_command} configtest && sudo #{web_command} reload) | ||
end | ||
|
||
desc "Stop the web servers" | ||
|
||
remote_task :stop_web, :roles => :web do | ||
run "#{web_command} stop" | ||
end | ||
|
||
## | ||
# Everything HTTP. | ||
|
||
desc "(Re)Start the web and app servers" | ||
|
||
remote_task :start do | ||
Rake::Task['vlad:start_app'].invoke | ||
Rake::Task['vlad:start_web'].invoke | ||
end | ||
|
||
remote_task :stop do | ||
Rake::Task['vlad:stop_app'].invoke | ||
Rake::Task['vlad:stop_web'].invoke | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# $GEM_HOME/gems/vlad-1.2.0/lib/vlad/thin.rb | ||
# Thin tasks for Vlad the Deployer | ||
# By cnantais | ||
require 'vlad' | ||
|
||
namespace :vlad do | ||
## | ||
# Thin app server | ||
|
||
set :thin_address, "127.0.0.1" | ||
set :thin_command, 'thin' | ||
set(:thin_conf) { "#{shared_path}/thin_cluster.conf" } | ||
set :thin_environment, "production" | ||
set :thin_group, nil | ||
set :thin_log_file, nil | ||
set :thin_pid_file, nil | ||
set :thin_port, nil | ||
set :thin_socket, "/tmp/thin.sock" | ||
set :thin_prefix, nil | ||
set :thin_servers, 2 | ||
set :thin_user, nil | ||
set :thin_rackup, nil | ||
|
||
desc "Prepares application servers for deployment. thin | ||
configuration is set via the thin_* variables.".cleanup | ||
|
||
remote_task :setup_app, :roles => :app do | ||
cmd = [ | ||
"#{thin_command} config", | ||
"-s #{thin_servers}", | ||
"-S #{thin_socket}", | ||
"-e #{thin_environment}", | ||
"-c #{current_path}", | ||
"-C #{thin_conf}", | ||
("-a #{thin_address}" if thin_address) | ||
("-R #{thin_rackup}" if thin_rackup ) | ||
("-P #{thin_pid_file}" if thin_pid_file), | ||
("-l #{thin_log_file}" if thin_log_file), | ||
("--user #{thin_user}" if thin_user), | ||
("--group #{thin_group}" if thin_group), | ||
("--prefix #{thin_prefix}" if thin_prefix), | ||
("-p #{thin_port}" if thin_port), | ||
].compact.join ' ' | ||
|
||
run cmd | ||
end | ||
|
||
def thin(cmd) # :nodoc: | ||
"#{thin_command} #{cmd} -C #{thin_conf}" | ||
end | ||
|
||
desc "Restart the app servers" | ||
|
||
remote_task :start_app, :roles => :app do | ||
run thin("restart -s #{thin_servers}") | ||
end | ||
|
||
desc "Stop the app servers" | ||
|
||
remote_task :stop_app, :roles => :app do | ||
run thin("stop -s #{thin_servers}") | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
require 'vlad' | ||
|
||
namespace :vlad do | ||
namespace :web do | ||
remote_task :enable, :roles => [:web] do | ||
run "if [ -f #{shared_path}/system/maintenance.html ]; then rm -f #{shared_path}/system/maintenance.html; fi" | ||
end | ||
remote_task :disable, :roles => [:web] do | ||
run "cp -f #{shared_path}/config/maintenance.html #{shared_path}/system/" | ||
end | ||
end | ||
end |