This file is indexed.

/usr/share/perl5/RunApp.pm is in librunapp-perl 0.13-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
package RunApp;
use strict;
use base qw(RunApp::Control);
our $VERSION = '0.13';

=head1 NAME

RunApp - A generic module to run web-applications

=head1 SYNOPSIS

 use RunApp '-chdir';

 use RunApp;
 use RunApp::Apache;

 my $cmd = shift || 'development';
 my $config = { var => 'value', app_apache => { var_for_apache => 'value'} };
 RunApp->new (app_apache => RunApp::Apache->new
                    (root => catfile (cwd, $_),
                     httpd => '/path/to/httpd'),
              my_daemon => RunApp::Control::AppControl->new
                    (binary => '/path/to/daemon',
                     args => ['--daemon'],
                     pidfile => '/path/to/daemon.pid',
                    )
                 )->$cmd ($config);

=head1 DESCRIPTION

C<RunApp> streamlines the process for configuring applications
that requires one or more web servers and/or other daemons, during
development or deployment.

It builds the config files required by the services from the
C<$config> hash, such as apache's httpd.conf.

=head1 OPTIONS

 use RunApp '-chdir';
 use RunApp qw(-chdir ..);

This will cause the your script to C<chdir> to the base directory.  If
it's a symbolic link it will be resolved and you will be in the
directory of where the original script is.  The C<lib> directory will
be added into C<@INC>, and you can use the modules in that path.

It also takes an optional relative path if want the script to chdir to
somewhere else.

This makes it possible for symlinking the your runapp script into
system's rc.d startup directory.

=head1 CONSTRUCTOR

=head2 new (@services)

C<@services> is actually an hash, with keys being the name of the
service, and values being C<RunApp::Control> objects.  Use an
array instead of a hash here to retain the order of dispatching.

The names are used to pick config from the hash, which will be flatten
into top level of the config hash, when running C<build> for the each
service.

=cut

use File::Spec::Functions qw(catdir splitpath);
use Cwd;

sub import {
  my $class = shift;
  my $opt = shift or return;
  if ($opt eq '-chdir') {
    my $dir = shift;
    $0 = Cwd::abs_path ($0);
    my (undef, $path) = splitpath ($0);
    chop $path if length $path > 1;
    $path = catdir ($path, $dir) if defined $dir;
    $path ||= Cwd::cwd;
    unshift @INC, catdir ($path, 'lib');
    chdir ($path);
  }
}

sub new {
  my $class = shift;
  my $self = $class->SUPER::new;
  $self->services (@_);
  return $self;
}

sub dispatch {
  my $self = shift;
  my $cmd = shift;
  $_->$cmd (@_) for @{$self->services}{@{$self->{order}}};
}

sub services {
  my $self = shift;
  if (@_) {
      my $key;
      $self->{order} = [grep { ($key = !$key) ? $_ : ()} @_];
      $self->{services} = {@_};
  }
  $self->{services};
}

=head1 METHODS

=head2 $self->development ($conf)

Runs C<build> and C<start>, and then waits for SIGINT to <stop> the
servers.

=cut

sub development {
  my ($self, $conf) = @_;
  $self->build ($conf);
  $self->start;
  $self->report ($conf);
  local $SIG{INT} = sub { $self->stop; exit };
  $self->debug if $conf->{debug};
  select (undef, undef, undef, undef);
}

sub build {
  my ($self, $conf) = @_;
  for (@{$self->{order}}) {
    my $subconf = ref $conf->{$_} ? $conf->{$_} : {};
    next unless $self->services->{$_};
    $self->services->{$_}->build ( {%$conf, %$subconf} );
  }
}

=head1 AUTOLOAD

All other methods are dispatched to the C<RunApp::Control> objects in
the order called in CONSTRUCTOR.  Note that this is done with
L<RunApp::Control> dispatching to the C<dispatch> method.

=head1 SEE ALSO

L<RunApp::Apache>, L<RunApp::Control::AppControl>, L<App::Control>

=head1 AUTHORS

Chia-liang Kao <clkao@clkao.org>

Refactored from works by Leon Brocard E<lt>acme@astray.comE<gt> and
Tom Insam E<lt>tinsam@fotango.comE<gt>.

=head1 COPYRIGHT

Copyright (C) 2002-5, Fotango Ltd.

This module is free software; you can redistribute it or modify it
under the same terms as Perl itself.

=cut

1;