| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::ForExample::Catalog; |
|
2
|
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
25
|
use strict; |
|
|
4
|
|
|
|
|
6
|
|
|
|
4
|
|
|
|
|
134
|
|
|
4
|
4
|
|
|
4
|
|
19
|
use warnings; |
|
|
4
|
|
|
|
|
7
|
|
|
|
4
|
|
|
|
|
1015
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
{ |
|
7
|
|
|
|
|
|
|
my ( @catalog, $catalog ); |
|
8
|
|
|
|
|
|
|
sub catalog { |
|
9
|
0
|
|
0
|
0
|
0
|
|
return $catalog ||= { @catalog }; |
|
10
|
|
|
|
|
|
|
} |
|
11
|
|
|
|
|
|
|
push @catalog, |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
'common' => { |
|
14
|
|
|
|
|
|
|
'catalyst/apache2/name-alias-log', => <<'_END_', |
|
15
|
|
|
|
|
|
|
ServerName [% hostname %] |
|
16
|
|
|
|
|
|
|
ServerAlias www.[% hostname %] |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
CustomLog "|/usr/bin/cronolog [% log_home %]/apache2-[% hostname %]-%Y-%m.access.log -S [% log_home %]/apache2-[% hostname %].access.log" combined |
|
19
|
|
|
|
|
|
|
ErrorLog "|/usr/bin/cronolog [% log_home %]/apache2-[% hostname %]-%Y-%m.error.log -S [% log_home %]/apache2-[% hostname %].error.log" |
|
20
|
|
|
|
|
|
|
_END_ |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
'catalyst/apache2/fastcgi-rewrite-rule' => <<'_END_', |
|
23
|
|
|
|
|
|
|
[%- IF base.length -%] |
|
24
|
|
|
|
|
|
|
# Optionally, rewrite the path when accessed without a trailing slash |
|
25
|
|
|
|
|
|
|
RewriteRule ^/[% base %]\$ [% base %]/ [R] |
|
26
|
|
|
|
|
|
|
[%- END -%] |
|
27
|
|
|
|
|
|
|
_END_ |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
}, |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
'catalyst/fastcgi/apache2/static' => \<<'_END_', |
|
32
|
|
|
|
|
|
|
# vim: set filetype=apache |
|
33
|
|
|
|
|
|
|
<VirtualHost *:80> |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
[% INCLUDE "catalyst/apache2/name-alias-log" -%] |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
FastCgiServer [% fastcgi_script %] -processes 3 |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Alias [% alias_base %] [% fastcgi_script %]/ |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
[% INCLUDE "catalyst/apache2/fastcgi-rewrite-rule" -%] |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
</VirtualHost> |
|
44
|
|
|
|
|
|
|
_END_ |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
'catalyst/fastcgi/apache2/standalone' => \<<'_END_', |
|
47
|
|
|
|
|
|
|
# vim: set filetype=apache |
|
48
|
|
|
|
|
|
|
<VirtualHost *:80> |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
[% INCLUDE "catalyst/apache2/name-alias-log" -%] |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
FastCgiExternalServer [% fastcgi_socket_path %] [% fastcgi_host_port ? "-host" : "-socket" %] [% fastcgi_socket %] |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Alias [% alias_base %] [% fastcgi_socket_path %]/ |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
[% INCLUDE "catalyst/apache2/fastcgi-rewrite-rule" -%] |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
<Directory "[% home %]/root"> |
|
59
|
|
|
|
|
|
|
Options Indexes FollowSymLinks |
|
60
|
|
|
|
|
|
|
AllowOverride All |
|
61
|
|
|
|
|
|
|
Order allow,deny |
|
62
|
|
|
|
|
|
|
Allow from all |
|
63
|
|
|
|
|
|
|
</Directory> |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
</VirtualHost> |
|
66
|
|
|
|
|
|
|
_END_ |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
'catalyst/fastcgi/apache2/dynamic' => \<<'_END_', |
|
69
|
|
|
|
|
|
|
# vim: set filetype=apache |
|
70
|
|
|
|
|
|
|
<VirtualHost *:80> |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
[% INCLUDE "catalyst/apache2/name-alias-log" -%] |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# TODO Need trailing slash? |
|
75
|
|
|
|
|
|
|
Alias [% alias_base %] [% fastcgi_script %]/ |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
[% INCLUDE "catalyst/apache2/fastcgi-rewrite-rule" -%] |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
<Directory "[% home %]/script"> |
|
80
|
|
|
|
|
|
|
Options +ExecCGI |
|
81
|
|
|
|
|
|
|
</Directory> |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
<Files "[% fastcgi_script_basename %]"> |
|
84
|
|
|
|
|
|
|
SetHandler fastcgi-script |
|
85
|
|
|
|
|
|
|
</Files> |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
</VirtualHost> |
|
88
|
|
|
|
|
|
|
_END_ |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
'catalyst/mod_perl/apache2' => \<<'_END_', |
|
91
|
|
|
|
|
|
|
PerlSwitches -I[% home %]/lib |
|
92
|
|
|
|
|
|
|
PerlModule [% package %] |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
<VirtualHost *:80> |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
[% INCLUDE "catalyst/apache2/name-alias-log" -%] |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
<Location "[% base %]"> |
|
99
|
|
|
|
|
|
|
SetHandler modperl |
|
100
|
|
|
|
|
|
|
PerlResponseHandler [% package %] |
|
101
|
|
|
|
|
|
|
</Location> |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
</VirtualHost> |
|
104
|
|
|
|
|
|
|
_END_ |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
'catalyst/fastcgi/start-stop' => \<<'_END_', |
|
107
|
|
|
|
|
|
|
#!/bin/bash |
|
108
|
|
|
|
|
|
|
# A very basic start-stop script, see also: |
|
109
|
|
|
|
|
|
|
# http://dev.catalystframework.org/wiki/gettingstarted/howtos/deploy/lighttpd_fastcgi |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
APP_PID_FILE="[% fastcgi_pid_file %]" |
|
112
|
|
|
|
|
|
|
APP_HOME="[% home %]" |
|
113
|
|
|
|
|
|
|
APP_NAME="[% name %]" |
|
114
|
|
|
|
|
|
|
APP_PACKAGE="[% package %]" |
|
115
|
|
|
|
|
|
|
APP_ERROR_LOG="[% log_home %]/`basename $APP_PID_FILE-error.log`" |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
case "$1" in |
|
118
|
|
|
|
|
|
|
start) |
|
119
|
|
|
|
|
|
|
echo -n "Starting $APP_NAME ($APP_PACKAGE) in $APP_HOME..." |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
if [ -r $APP_PID_FILE ]; then |
|
122
|
|
|
|
|
|
|
echo " $APP_NAME is already running" |
|
123
|
|
|
|
|
|
|
echo "Already started" |
|
124
|
|
|
|
|
|
|
exit -1 |
|
125
|
|
|
|
|
|
|
fi |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
cd $APP_HOME |
|
128
|
|
|
|
|
|
|
[% fastcgi_script %] -l [% fastcgi_socket %] -n 5 -p $APP_PID_FILE -keeperr 2>>$APP_ERROR_LOG & |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
# Wait for the application to start |
|
131
|
|
|
|
|
|
|
TIMEOUT=10; while [ ! -r $APP_PID_FILE ]; do |
|
132
|
|
|
|
|
|
|
echo -n '.'; sleep 1; TIMEOUT=$[$TIMEOUT - 1] |
|
133
|
|
|
|
|
|
|
if [ $TIMEOUT = 0 ]; then |
|
134
|
|
|
|
|
|
|
echo " NOT starting? (timeout)"; exit -1 |
|
135
|
|
|
|
|
|
|
fi |
|
136
|
|
|
|
|
|
|
done |
|
137
|
|
|
|
|
|
|
echo "done" |
|
138
|
|
|
|
|
|
|
PID=`cat "$APP_PID_FILE"` |
|
139
|
|
|
|
|
|
|
echo "Started $APP_NAME ($APP_PACKAGE) (process $PID)" |
|
140
|
|
|
|
|
|
|
;; |
|
141
|
|
|
|
|
|
|
stop) |
|
142
|
|
|
|
|
|
|
echo -n "Stopping $APP_NAME ($APP_PACKAGE)... " |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
if [ -s "$APP_PID_FILE" ]; then |
|
145
|
|
|
|
|
|
|
PID=`cat "$APP_PID_FILE"` |
|
146
|
|
|
|
|
|
|
echo -n "Killing process $PID... " |
|
147
|
|
|
|
|
|
|
kill $PID |
|
148
|
|
|
|
|
|
|
echo -n "done. Wating for $APP_PID_FILE to be culled..." |
|
149
|
|
|
|
|
|
|
TIMEOUT=10; while [ -r $APP_PID_FILE ]; do |
|
150
|
|
|
|
|
|
|
echo -n '.'; sleep 1; TIMEOUT=$[$TIMEOUT - 1] |
|
151
|
|
|
|
|
|
|
if [ $TIMEOUT = 0 ]; then |
|
152
|
|
|
|
|
|
|
echo " NOT stopping? (timeout)"; exit -1 |
|
153
|
|
|
|
|
|
|
fi |
|
154
|
|
|
|
|
|
|
done |
|
155
|
|
|
|
|
|
|
echo "done" |
|
156
|
|
|
|
|
|
|
echo "Stopped $APP_NAME ($APP_PACKAGE)" |
|
157
|
|
|
|
|
|
|
else |
|
158
|
|
|
|
|
|
|
echo "$APP_NAME is not running" |
|
159
|
|
|
|
|
|
|
echo "Already stopped" |
|
160
|
|
|
|
|
|
|
exit -1 |
|
161
|
|
|
|
|
|
|
fi |
|
162
|
|
|
|
|
|
|
;; |
|
163
|
|
|
|
|
|
|
restart) |
|
164
|
|
|
|
|
|
|
$0 stop |
|
165
|
|
|
|
|
|
|
sleep 2 |
|
166
|
|
|
|
|
|
|
$0 start |
|
167
|
|
|
|
|
|
|
;; |
|
168
|
|
|
|
|
|
|
status|about) |
|
169
|
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
echo "Status for $APP_NAME ($APP_PACKAGE)" |
|
171
|
|
|
|
|
|
|
echo " home: $APP_HOME" |
|
172
|
|
|
|
|
|
|
echo " log: $APP_ERROR_LOG" |
|
173
|
|
|
|
|
|
|
echo -n " pid: " |
|
174
|
|
|
|
|
|
|
if [ -s "$APP_PID_FILE" ]; then |
|
175
|
|
|
|
|
|
|
PID=`cat "$APP_PID_FILE"` |
|
176
|
|
|
|
|
|
|
echo -n $PID |
|
177
|
|
|
|
|
|
|
else |
|
178
|
|
|
|
|
|
|
echo -n " -" |
|
179
|
|
|
|
|
|
|
fi |
|
180
|
|
|
|
|
|
|
echo " ($APP_PID_FILE)" |
|
181
|
|
|
|
|
|
|
;; |
|
182
|
|
|
|
|
|
|
*) |
|
183
|
|
|
|
|
|
|
echo "Don't understand \"$1\" ($*)" |
|
184
|
|
|
|
|
|
|
echo "Usage: $0 { start | stop | restart | status }" |
|
185
|
|
|
|
|
|
|
exit -1 |
|
186
|
|
|
|
|
|
|
;; |
|
187
|
|
|
|
|
|
|
esac |
|
188
|
|
|
|
|
|
|
_END_ |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
'catalyst/fastcgi/monit' => \<<'_END_', |
|
191
|
|
|
|
|
|
|
check process [% name %]-fastcgi with pidfile [% fastcgi_pid_file %] |
|
192
|
|
|
|
|
|
|
start program = "[% home %]/fastcgi-start-stop start" |
|
193
|
|
|
|
|
|
|
stop program = "[% home %]/fastcgi-start-stop stop" |
|
194
|
|
|
|
|
|
|
_END_ |
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
'catalyst/fastcgi/lighttpd/standalone' => \<<'_END_', |
|
197
|
|
|
|
|
|
|
server.modules += ( "mod_fastcgi" ) |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
$HTTP["host"] =~ "^(www.)?[% hostname %]" { |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
# The location for accesslog needs to be accessible/writable by the lighttpd user |
|
202
|
|
|
|
|
|
|
accesslog.filename = "|/usr/bin/cronolog [% log_home %]/lighttpd-[% hostname %]-%Y-%m.access.log -S [% log_home %]/lighttpd-[% hostname %].access.log" |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
fastcgi.server = ( |
|
205
|
|
|
|
|
|
|
"[% base %]" => ( |
|
206
|
|
|
|
|
|
|
"[% name %]" => ( |
|
207
|
|
|
|
|
|
|
[% IF fastcgi_host_port %] |
|
208
|
|
|
|
|
|
|
"host" => "[% fastcgi_host_port.0 %]", |
|
209
|
|
|
|
|
|
|
"port" => [% fastcgi_host_port.1 %], |
|
210
|
|
|
|
|
|
|
[% ELSE %] |
|
211
|
|
|
|
|
|
|
"socket" => "/tmp/[% name %].socket", |
|
212
|
|
|
|
|
|
|
[% END %] |
|
213
|
|
|
|
|
|
|
"check-local" => "disable" |
|
214
|
|
|
|
|
|
|
) |
|
215
|
|
|
|
|
|
|
) |
|
216
|
|
|
|
|
|
|
) |
|
217
|
|
|
|
|
|
|
} |
|
218
|
|
|
|
|
|
|
_END_ |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
'catalyst/fastcgi/lighttpd/static' => \<<'_END_', |
|
221
|
|
|
|
|
|
|
server.modules += ( "mod_fastcgi" ) |
|
222
|
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
$HTTP["host"] =~ "^(www.)?[% hostname %]" { |
|
224
|
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
# The location for accesslog needs to be accessible/writable by the lighttpd user |
|
226
|
|
|
|
|
|
|
accesslog.filename = "|/usr/bin/cronolog [% log_home %]/lighttpd-[% hostname %]-%Y-%m.access.log -S [% log_home %]/lighttpd-[% hostname %].access.log" |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
fastcgi.server = ( |
|
229
|
|
|
|
|
|
|
"[% base %]" => ( |
|
230
|
|
|
|
|
|
|
"[% name%]" => ( |
|
231
|
|
|
|
|
|
|
"socket" => "[% fastcgi_socket %]", |
|
232
|
|
|
|
|
|
|
"check-local" => "disable", |
|
233
|
|
|
|
|
|
|
"bin-path" => "[% fastcgi_script %]", |
|
234
|
|
|
|
|
|
|
"min-procs" => 2, |
|
235
|
|
|
|
|
|
|
"max-procs" => 5, |
|
236
|
|
|
|
|
|
|
"idle-timeout" => 20 |
|
237
|
|
|
|
|
|
|
) |
|
238
|
|
|
|
|
|
|
) |
|
239
|
|
|
|
|
|
|
) |
|
240
|
|
|
|
|
|
|
} |
|
241
|
|
|
|
|
|
|
_END_ |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
'catalyst/fastcgi/nginx' => \<<'_END_', |
|
244
|
|
|
|
|
|
|
server { |
|
245
|
|
|
|
|
|
|
server_name [% hostname %]; |
|
246
|
|
|
|
|
|
|
access_log [% log_home %]/nginx-[% hostname %].access.log; |
|
247
|
|
|
|
|
|
|
error_log [% log_home %]/nginx-[% hostname %].error.log; |
|
248
|
|
|
|
|
|
|
location [% alias_base %] { |
|
249
|
|
|
|
|
|
|
include fastcgi_params; |
|
250
|
|
|
|
|
|
|
[% IF fastcgi_host_port %] |
|
251
|
|
|
|
|
|
|
fastcgi_pass [% fastcgi_socket %]; |
|
252
|
|
|
|
|
|
|
[% ELSE %] |
|
253
|
|
|
|
|
|
|
fastcgi_pass unix:[% fastcgi_socket %]; |
|
254
|
|
|
|
|
|
|
[% END %] |
|
255
|
|
|
|
|
|
|
} |
|
256
|
|
|
|
|
|
|
} |
|
257
|
|
|
|
|
|
|
_END_ |
|
258
|
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
'monit' => \<<'_END_', |
|
260
|
|
|
|
|
|
|
# Monit control file |
|
261
|
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
set daemon 120 |
|
263
|
|
|
|
|
|
|
#set alert alice+hostname.monit@example.com |
|
264
|
|
|
|
|
|
|
set logfile [% home %]/log |
|
265
|
|
|
|
|
|
|
set pidfile [% home %]/pid |
|
266
|
|
|
|
|
|
|
set statefile [% home %]/state |
|
267
|
|
|
|
|
|
|
|
|
268
|
|
|
|
|
|
|
set httpd port 2822 and # This port needs to be unique on a system |
|
269
|
|
|
|
|
|
|
use address localhost |
|
270
|
|
|
|
|
|
|
allow localhost |
|
271
|
|
|
|
|
|
|
|
|
272
|
|
|
|
|
|
|
# Put this file in [% home %]/monitrc |
|
273
|
|
|
|
|
|
|
# Use this alias to control your monit daemon: |
|
274
|
|
|
|
|
|
|
# |
|
275
|
|
|
|
|
|
|
# alias 'my-monit'='monit -vc [% home %]/monitrc' |
|
276
|
|
|
|
|
|
|
# |
|
277
|
|
|
|
|
|
|
# my-monit |
|
278
|
|
|
|
|
|
|
# my-monit start all |
|
279
|
|
|
|
|
|
|
# my-monit quit |
|
280
|
|
|
|
|
|
|
# my-monit validate |
|
281
|
|
|
|
|
|
|
# ... |
|
282
|
|
|
|
|
|
|
# |
|
283
|
|
|
|
|
|
|
_END_ |
|
284
|
|
|
|
|
|
|
; |
|
285
|
|
|
|
|
|
|
} |
|
286
|
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
1; |