File: utils.pm

package info (click to toggle)
libfcgi-engine-perl 0.22-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 360 kB
  • sloc: perl: 3,226; makefile: 2
file content (41 lines) | stat: -rw-r--r-- 784 bytes parent folder | download | duplicates (3)
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
package utils;

use strict;
use warnings;

use Path::Class::File;

sub find_lighttpd {
    my $lighttpd = map { chomp; $_ } `which lighttpd`;

    if ( ! -x "$lighttpd" ) {
    PREFIX:    
        for my $prefix (qw(/usr /usr/local /opt/local /sw)) {
            for my $bindir (qw(bin sbin)) { 
                $lighttpd="$prefix/$bindir/lighttpd";
                last PREFIX if -x "$lighttpd"
            }
        }
    }

    return unless -x $lighttpd;    
    return $lighttpd;
}

sub lighttpd_pidfile {
    Path::Class::File->new('/tmp/lighttpd.pid')
}

sub start_lighttpd {
    my $conf = shift;
    system(find_lighttpd(), '-f', $conf);    
}

sub stop_lighttpd {
    my $signal = shift || 'TERM';
    kill $signal => ((lighttpd_pidfile)->slurp(chomp => 1));
}

1;

__END__