-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathStatic.pm
85 lines (70 loc) · 1.66 KB
/
Static.pm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# (c)
#
# vim: set ts=2 sw=2 tw=0:
# vim: set expandtab:
package Application::Static;
use Moose;
use Rex::Commands::Run;
extends qw(Application::Base);
has vhost => (
is => 'ro',
lazy => 1,
default => sub {
my $self = shift;
$self->defaults->{vhost};
},
);
has post_configuration => (
is => 'ro',
default => sub { 1 },
);
has '+defaults' => (
default => sub {
my $self = shift;
return {
document_root_directory => "app",
deploy_stash_directory => "deploy",
deploy_configuration_directory => "conf",
data_directory => "shared",
manager_path => "manager",
instance_prefix => ( $ENV{"instance_prefix"} || "i" ),
vhost => $ENV{vhost},
deploy_path => File::Spec->catdir( $self->project->project_path, "www" ),
},
;
},
);
override get_instances => sub {
my ($self) = @_;
my $instance_class = ref($self) . "::Instance";
return (
$instance_class->new(
app => $self,
instance => $self->project->defaults->{vhost},
instance_path => File::Spec->catdir(
(
$self->project->defaults->{deploy_path}
|| $self->project->defaults->{instance_path}
),
$self->project->defaults->{vhost}
),
)
);
};
override switch => sub {
my ($self) = @_;
my $inactive = $self->get_deployable_instance;
$inactive->activate;
};
Project->register_app_type(
1000,
__PACKAGE__,
sub {
my @httpd_out = run "rpm -qa | grep httpd";
if ( scalar @httpd_out >= 1 ) {
return 1;
}
return 0;
}
);
1;