line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# (c) Jan Gehring |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# vim: set ts=2 sw=2 tw=0: |
5
|
|
|
|
|
|
|
# vim: set expandtab: |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
Rex::Apache::Deploy - Deploy module for Rex |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 DESCRIPTION |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
This is a (R)?ex module to ease the deployments of Tomcat, Perl, Rails, PHP or other languages. |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
You can find examples and howtos on L |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 GETTING HELP |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=over 4 |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=item * Web Site: L |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=item * IRC: irc.freenode.net #rex |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=back |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 DEPENDENCIES |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=over 4 |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=item * |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
L |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=item * |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
L |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=item * |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
L |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=item * |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
zip |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=item * |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
unzip |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=item * |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
tar |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=item * |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
bzip2 |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=item * |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
wget |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=back |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
If you're using windows, you can install them from here: http://sourceforge.net/projects/gnuwin32/files/ |
66
|
|
|
|
|
|
|
Don't forget to add the bin directory of the installation to your %PATH% environment variable. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 SYNOPSIS |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
use Rex::Apache::Deploy Symlink; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
deploy_to "/var/deploy"; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
document_root "/var/www/myhost/htdocs"; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
generate_deploy_directory sub { |
77
|
|
|
|
|
|
|
my ($file) = @_; |
78
|
|
|
|
|
|
|
$file =~ m/-(\d+\.\d+\.\d+)\.tar\.gz$/; |
79
|
|
|
|
|
|
|
return $1; |
80
|
|
|
|
|
|
|
}; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
desc "Deploy to Apache"; |
83
|
|
|
|
|
|
|
task "deploy", group => "frontend", sub { |
84
|
|
|
|
|
|
|
deploy "mypkg-1.0.1.tar.gz"; |
85
|
|
|
|
|
|
|
}; |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 DEPLOY METHODS |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=over 4 |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=item Symlink |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
This method will upload your package (*.tar.gz, *.tar.bz2 or *.zip) all you servers and extract it in the directory you specified with I concatenated with the result of I. After that it will create a symlink from I to this new directory. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
deploy_to "/var/deploy"; |
97
|
|
|
|
|
|
|
document_root "/var/www"; |
98
|
|
|
|
|
|
|
generate_deploy_directory sub { return "1.0"; }; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
This will upload the file to I and create a symlink from I to I. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=item Tomcat |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
This method is for Tomcat deployments. You need to have the Tomcat Manage application running on your Tomcat servers. It will upload your package to I, call the Tomcat Manager to undeploy the current context and deploy the new war archive. After that it will delete the uploaded temporary war file. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
context_path "/myapp"; |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
task "deploy", group => "middleware", sub { |
109
|
|
|
|
|
|
|
deploy "myapp.war", |
110
|
|
|
|
|
|
|
username => "manager-user", |
111
|
|
|
|
|
|
|
password => "manager-password", |
112
|
|
|
|
|
|
|
port => 8080, |
113
|
|
|
|
|
|
|
manager_url => "/manager"; |
114
|
|
|
|
|
|
|
}; |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
This will deploy I to the tomcat listening on port I<8080> with the manager application found under I. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=back |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 SWITCHING INSTANCES |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
If you have multiple Tomcat Instances you can manage them with the I command. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
jk disable => 'name'; |
125
|
|
|
|
|
|
|
jk enable => 'name'; |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
package Rex::Apache::Deploy; |
131
|
|
|
|
|
|
|
|
132
|
1
|
|
|
1
|
|
1980
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
133
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
25
|
|
134
|
|
|
|
|
|
|
|
135
|
1
|
|
|
1
|
|
6
|
use Data::Dumper; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
44
|
|
136
|
1
|
|
|
1
|
|
6
|
use Rex::Commands::Run; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
137
|
1
|
|
|
1
|
|
81
|
use Rex::Logger; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
138
|
|
|
|
|
|
|
|
139
|
1
|
|
|
1
|
|
26
|
use Cwd qw(getcwd); |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
163
|
|
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
our $VERSION = '0.12.0'; |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
###### commonly used |
144
|
|
|
|
|
|
|
our @COMMONS = (); |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
sub import { |
147
|
|
|
|
|
|
|
|
148
|
1
|
|
|
1
|
|
10
|
my ($call_class) = caller; |
149
|
1
|
50
|
|
|
|
5
|
return unless $call_class; |
150
|
|
|
|
|
|
|
|
151
|
1
|
50
|
|
|
|
10
|
return unless $_[1]; |
152
|
|
|
|
|
|
|
|
153
|
0
|
0
|
|
|
|
|
die("Invalid input format") unless ( $_[1] =~ m/^[a-z0-9_]+$/i ); |
154
|
|
|
|
|
|
|
|
155
|
1
|
|
|
1
|
|
5
|
no strict 'refs'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
67
|
|
156
|
0
|
|
|
|
|
|
for my $exp (@COMMONS) { |
157
|
0
|
|
|
|
|
|
*{"${call_class}::$exp"} = \&$exp; |
|
0
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
} |
159
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
68
|
|
160
|
|
|
|
|
|
|
|
161
|
0
|
|
|
|
|
|
eval "use $_[0]::$_[1] '$call_class';"; |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
1; |