|
74c348b2
»
|
macournoyer |
2008-02-07 |
Add tasks for Vlad the Depl... |
1 |
# $GEM_HOME/gems/vlad-1.2.0/lib/vlad/thin.rb |
| |
2 |
# Thin tasks for Vlad the Deployer |
| |
3 |
# By cnantais |
| |
4 |
require 'vlad' |
| |
5 |
|
| |
6 |
namespace :vlad do |
| |
7 |
## |
| |
8 |
# Thin app server |
| |
9 |
|
| |
10 |
set :thin_address, "127.0.0.1" |
| |
11 |
set :thin_command, 'thin' |
| |
12 |
set(:thin_conf) { "#{shared_path}/thin_cluster.conf" } |
| |
13 |
set :thin_environment, "production" |
| |
14 |
set :thin_group, nil |
| |
15 |
set :thin_log_file, nil |
| |
16 |
set :thin_pid_file, nil |
| |
17 |
set :thin_port, nil |
| |
18 |
set :thin_socket, "/tmp/thin.sock" |
| |
19 |
set :thin_prefix, nil |
| |
20 |
set :thin_servers, 2 |
| |
21 |
set :thin_user, nil |
| |
22 |
|
| |
23 |
desc "Prepares application servers for deployment. thin |
| |
24 |
configuration is set via the thin_* variables.".cleanup |
| |
25 |
|
| |
26 |
remote_task :setup_app, :roles => :app do |
| |
27 |
cmd = [ |
| |
28 |
"#{thin_command} config", |
| |
29 |
"-s #{thin_servers}", |
| |
30 |
"-S #{thin_socket}", |
| |
31 |
"-e #{thin_environment}", |
| |
32 |
"-a #{thin_address}", |
| |
33 |
"-c #{current_path}", |
| |
34 |
"-C #{thin_conf}", |
| |
35 |
("-P #{thin_pid_file}" if thin_pid_file), |
| |
36 |
("-l #{thin_log_file}" if thin_log_file), |
| |
37 |
("--user #{thin_user}" if thin_user), |
| |
38 |
("--group #{thin_group}" if thin_group), |
| |
39 |
("--prefix #{thin_prefix}" if thin_prefix), |
| |
40 |
("-p #{thin_port}" if thin_port), |
| |
41 |
].compact.join ' ' |
| |
42 |
|
| |
43 |
run cmd |
| |
44 |
end |
| |
45 |
|
| |
46 |
def thin(cmd) # :nodoc: |
| |
47 |
"#{thin_command} #{cmd} -C #{thin_conf}" |
| |
48 |
end |
| |
49 |
|
| |
50 |
desc "Restart the app servers" |
| |
51 |
|
| |
52 |
remote_task :start_app, :roles => :app do |
| |
53 |
run thin("restart -s #{thin_servers}") |
| |
54 |
end |
| |
55 |
|
| |
56 |
desc "Stop the app servers" |
| |
57 |
|
| |
58 |
remote_task :stop_app, :roles => :app do |
| |
59 |
run thin("stop -s #{thin_servers}") |
| |
60 |
end |
| |
61 |
end |